java - scrollbars adjust when zooming using Jxlayer and PBar extensions -
i tried use jxlayer , pbar extensions (using response of madprogrammer here) add zoom capability jpanel contained in jscrollpanel. zoom work fine when zoomed panel becomes larger containing jframe scrollbars doesn’t adjust , stay inactive. here code:
jframe frame = new jframe("testing"); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.setlayout(new borderlayout()); jpanel toppanel = new jpanel(); integer[] zoomlist = {50, 75, 100, 125, 150, 200}; jcombobox<integer> zoombox = new jcombobox<>(zoomlist); zoombox.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent ae) { int value = (int) zoombox.getselecteditem(); double scale = value / 100d; transformmodel.setscale(scale); } }); toppanel.add(zoombox); panel centerpanel = new testpane(); jscrollpane scrollpane = new jscrollpane(synopticpanel); scrollpane.sethorizontalscrollbarpolicy(jscrollpane.horizontal_scrollbar_always); scrollpane.setverticalscrollbarpolicy(jscrollpane.vertical_scrollbar_always); scrollpane.getviewport().setopaque(false); scrollpane.setopaque(false); frame.add(toppanel, borderlayout.north); frame.add(synopticpanel); frame.pack(); frame.setlocationrelativeto(null); frame.setvisible(true);
and in testpane class
public class testpane extends jpanel { private jlayer<jcomponent> layer; private jpanel content; public testpane() { content = new jpanel(); content.setlayout(null); //adding components transformmodel = new defaulttransformmodel(); transformmodel.setscaletopreferredsize(true); layer = transformutils.createtransformjlayer(content, transformmodel, null); setlayout(new borderlayout()); add(layer); }
thank help
Comments
Post a Comment