swing - Java: JComboBox -> ScrollBar - change color -
i'm working on small application. made jcombobox, , want change colours inside. changed colour background, foreground, arrowbutton, ... don't know how change colours scrollbar inside.
comobox = new jcombobox(); comobox.setname("currencycombo"); defaultcomboboxmodel combomodel = new defaultcomboboxmodel(); combomodel.addelement("gagd"); combomodel.addelement("agg"); combomodel.addelement("ehgsy"); combomodel.addelement("cgafgy"); combomodel.addelement("cfadgy"); combomodel.addelement("ggafg"); combomodel.addelement("sgfsdg"); combomodel.addelement("ugfasdg"); combomodel.addelement("fasfasf"); comobox.setmodel(combomodel); comobox.setopaque(true); uimanager.put( "combobox.disabledbackground", new java.awt.color(32, 34, 41)); uimanager.put( "combobox.disabledforeground", new java.awt.color(181, 181, 181)); uimanager.put( "combobox.background", new java.awt.color(32, 34, 41)); uimanager.put( "combobox.foreground", new java.awt.color(181, 181, 181)); uimanager.put( "combobox.selectionbackground", new java.awt.color(181, 181, 181)); uimanager.put( "combobox.selectionforeground", new java.awt.color(32, 34, 41)); comobox.setui(new basiccomboboxui(){ @override protected jbutton createarrowbutton() { jbutton arrowbutton = new basicarrowbutton( basicarrowbutton.south, new java.awt.color(32, 34, 41), new java.awt.color(181, 181, 181), new java.awt.color(181, 181, 181), new java.awt.color(32, 34, 41)); arrowbutton.setborder(borderfactory.createlineborder(new java.awt.color(32, 34, 41))); return arrowbutton; } });
i tried this:
object obejct = currencycombo.getui().getaccessiblechild(currencycombo, 0); component co = ((container) obejct).getcomponent(0) ; if( co instanceof jscrollpane){ jscrollpane pane = (jscrollpane) co; component[] components = pane.getcomponents(); (component component : components) { if(component instanceof jscrollbar) { jscrollbar jsb = (jscrollbar) component; jsb.setbackground(color.red); jsb.setforeground(color.blue); jsb.setui(new basicscrollbarui()); jsb.updateui(); } } }
hej jakub, following code change background of scrollbar inside combobox:
edit: can access color of scrollbar in these ways:
uimanager.put("scrollbar.thumbhighlight", color...; uimanager.put("scrollbar.thumbdarkshadow", color...; uimanager.put("scrollbar.highlight", color...; uimanager.put("scrollbar.trackhighlight", color...;
Comments
Post a Comment