8

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

Enter image description here

Seaglass

Enter image description here

How can I achieve that effect? Is overriding paint helpful here? What would a method be?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
chAmi
  • 1,774
  • 3
  • 20
  • 27
  • 5
    No, overriding paint isn't gaining to help, you will need to provide a new UI delegate capable of providing the support you need. The first place I'd start is having a look at the sea glass source code if you can and see if you find how they achieve it -IMHO – MadProgrammer Nov 08 '12 at 20:08
  • @MadProgrammer Yes. I tried to see what they've done it in seaglass at the first place. But didn't get much. I'll check about UI delegate. I'd be grateful if you can tell me a good source too. – chAmi Nov 09 '12 at 05:03
  • You could just download it from [here](http://code.google.com/p/seaglass/)? – MadProgrammer Nov 09 '12 at 05:33
  • @MadProgrammer ahh.. No not the seaglass code. I mean good source/example or tutorial for UI delegate with JCombobox. I like to check if you know. – chAmi Nov 09 '12 at 11:09
  • Best lace to start ismwithnthe sea glass combo box UI delegate, that will,give some ideas ono where/how they create the popup – MadProgrammer Nov 09 '12 at 11:13

1 Answers1

1

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:

enter image description here

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:

Renat Gilmanov
  • 17,735
  • 5
  • 39
  • 56
  • Thanks for your great answer, I really appreciate you, I was totally disappointed by the community as no one was here to give the answer, well, now just explain me how to make lines in JTextArea of a color, Just try if you can else I have decided to gift you the bounty. – MMujtabaRoohani Aug 17 '13 at 22:16
  • Be patient and community will surprise you. There are too many questions and virtually no spare time. Anyway, try not to use any kind of "blackmailing". JTextArea is a totally different question. Be smart and use search -- there are tons of recipes already, for example http://stackoverflow.com/questions/9650992/how-to-change-text-color-in-the-jtextarea – Renat Gilmanov Aug 17 '13 at 22:28
  • This is not a blackmailing, Just see my additional request written on bounty information area, I don't need to change either the jComboBox nor the JSlider, I needed to change jTextArea and jTable, and I have a Question of this also on the Community, please be positive, I just wanted you to help me out for this, while rendering jTable and other properties of jTextarea is easier – MMujtabaRoohani Aug 17 '13 at 22:36
  • I just gave you the bounty, can you please give me the answer now. – MMujtabaRoohani Aug 17 '13 at 22:51
  • Will try to answer your question. Thanks. – Renat Gilmanov Aug 19 '13 at 07:13
  • @JProgrammer, didn't find any separate questions related to JTextArea and JTable. Anyway, several hints to make your life easier: JTextArea is not supposed to be used that way. You should use JTextPane/JEditorPane instead. Here is a complete example: http://stackoverflow.com/a/9652143/1435741 try to use it (it is very straightforward, method appendToPane holds all the magic). Please also follow the default procedure and create separate questions. I believe you'll get enough support and good replies. Happy coding. – Renat Gilmanov Aug 19 '13 at 14:16
  • Thanks for your assistance, I will be creating a seperate Question for this soon. – MMujtabaRoohani Aug 20 '13 at 17:57