मुझे एक JScrollPane स्टाइल करने में परेशानी हो रही है। मैं सिर्फ अंगूठे और पृष्ठभूमि दोनों के रंग को बदलने में सक्षम होना चाहता हूं (और वृद्धि/कमी बटन भी हटाएं)।JScrollPane के अंगूठे रंग और पृष्ठभूमि रंग को बदलना?
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;
}
इसके अलावा
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)));
ऊपर कोड मैं एक सफेद पृष्ठभूमि के साथ एक अन्धेरा अंगूठे मिल के सभी के साथ
: अब तक मैं निम्नलिखित की कोशिश की है। अगर मैं setUI फ़ंक्शंस को हटा देता हूं तो मुझे काफी हद तक पर्याप्त लगता है, मुझे एक अंधेरे पृष्ठभूमि के साथ एक डिफ़ॉल्ट अंगूठा मिलता है ..
कोई विचार?
धन्यवाद
हल ** * ** *
configureScrollBarColors समारोह ऊपर निम्नलिखित तरीके से इस्तेमाल किया जा सकता:
@Override
protected void configureScrollBarColors(){
this.thumbColor = Color.GREEN;
}
जो अंगूठे के रंग को हरे रंग में बदल देता है।