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?
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.