java - Transparent JPanel in JLayeredPane -
i've seen several similar questions, unfortunately suggestions contained therein haven't quite done me.
the overall goal: have slider want display in upper left of window displays visualization (here "display"). slider should overlay on top of visualization without background.
so far, have jpanel containing slider on layer above visualization in jlayeredpane. problem that, despite calls setopaque and/or setbackground(new color(0,0,0,0)), background jpanel including slider appears grey. using nimbus laf.
originally, used absolute layout, accomplished quite elegantly , minimal code. issue there visualization didn't resize window automatically (but i'm open approach if there's clean way make visualization resize window).
jpanel sliderpane = new jpanel(); sliderpane.setlayout(new boxlayout(sliderpane, boxlayout.x_axis)); sliderpane.add(zoomslider); zoomslider.setmaximumsize(new dimension (60, 150)); sliderpane.add(box.createhorizontalglue()); sliderpane.setbackground(new color(0,0,0,0)); jlayeredpane graphpane = new jlayeredpane(); graphpane.setpreferredsize(new dimension(1000, 800)); graphpane.setlayout(new boxlayout(graphpane, boxlayout.y_axis)); graphpane.add(sliderpane, new integer(1)); graphpane.add(display, new integer(0)); graphpane.setopaque(false);
thanks much!
rendering slider responsibility of component's ui delegate, typically subclass of basicsliderui
. if required, can substitute own implementation, shown here.
Comments
Post a Comment