I am having problems with the design of JScrollPane. I just want to change the color of both the large and the background (and also remove the increase / decrease buttons). So far I have tried the following:
this.setBackground(new Color(0,0,0)); this.viewport.setBackground(new Color(0,0,0)); this.getViewport().setBackground(Color.BLACK); this.setOpaque(false); this.getVerticalScrollBar().setUI(new BasicScrollBarUI() { @Override protected JButton createDecreaseButton(int orientation) { return createZeroButton(); } @Override protected JButton createIncreaseButton(int orientation) { return createZeroButton(); } @Override protected void configureScrollBarColors(){ } }); this.getHorizontalScrollBar().setUI(new BasicScrollBarUI() { @Override protected JButton createDecreaseButton(int orientation) { return createZeroButton(); } @Override protected JButton createIncreaseButton(int orientation) { return createZeroButton(); } }); } private JButton createZeroButton() { JButton jbutton = new JButton(); jbutton.setPreferredSize(new Dimension(0, 0)); jbutton.setMinimumSize(new Dimension(0, 0)); jbutton.setMaximumSize(new Dimension(0, 0)); return jbutton; }
Besides
UIManager.put("ScrollBar.trackHighlightForeground", (new Color(57,57,57))); UIManager.put("scrollbar", (new Color(57,57,57))); UIManager.put("ScrollBar.thumb", new ColorUIResource(new Color(57,57,57))); UIManager.put("ScrollBar.thumbHeight", 2); UIManager.put("ScrollBar.background", (new Color(57,57,57))); UIManager.put("ScrollBar.thumbDarkShadow", new ColorUIResource(new Color(57,57,57))); UIManager.put("ScrollBar.thumbShadow", new ColorUIResource(new Color(57,57,57))); UIManager.put("ScrollBar.thumbHighlight", new ColorUIResource(new Color(57,57,57))); UIManager.put("ScrollBar.trackForeground", new ColorUIResource(new Color(57,57,57))); UIManager.put("ScrollBar.trackHighlight", new ColorUIResource(new Color(57,57,57))); UIManager.put("ScrollBar.foreground", new ColorUIResource(new Color(57,57,57))); UIManager.put("ScrollBar.shadow", new ColorUIResource(new Color(57,57,57))); UIManager.put("ScrollBar.highlight", new ColorUIResource(new Color(57,57,57)));
With all the above code, I get a darkened thumb with a white background. Oddly enough, if I remove the setUI functions, I get a default finger with a darkened background.
Any ideas?
thanks
solvable ******
the above configureScrollBarColors function can be used as follows:
@Override protected void configureScrollBarColors(){ this.thumbColor = Color.GREEN; }
This changes the color of the thumb to green.