Reputation: 1813
I'm using nimbus as L&F, but I really like to have a rounded shape combobox dropdown like seaglass L&F. See following images.
Nimbus
Seaglass
How can I achieve that effect? Is overriding paint helpful here? What would a method be?
Upvotes: 8
Views: 923
Reputation: 17895
Nimbus can be customized by updating UIManager properties. Example:
UIManager.put("nimbusBase", new Color(...));
UIManager.put("nimbusBlueGrey", new Color(...));
UIManager.put("control", new Color(...));
Painters can be updated as well. For example, custom slider:
The actual approach:
sliderDefaults.put("Slider.thumbWidth", 20);
sliderDefaults.put("Slider.thumbHeight", 20);
sliderDefaults.put("Slider:SliderThumb.backgroundPainter", new Painter() {
public void paint(Graphics2D g, JComponent c, int w, int h) {
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setStroke(new BasicStroke(2f));
g.setColor(Color.RED);
g.fillOval(1, 1, w-3, h-3);
g.setColor(Color.WHITE);
g.drawOval(1, 1, w-3, h-3);
}
});
Resources:
Upvotes: 1