0

I'm experimenting with JRadioButton's to put them on a JToolbar and select the last one clicked. If i'd use JButtons they wouldn't keep the Selection.

Since JRadioButton always have that Dot, I need to draw them myself by overriding the paint-methods.

The Button's will be circles with an Icon in it. That works if I draw Images, but looks aweful. The problem I have is that I would like to draw the circle so that these Buttons always look like the JButtons with the current LookAndFeel.

How can i do that? I searched for a while now, but I didn't find methods to read some default-colors of the LookAndFeel which I could use.

So how can i read Background-Colors etc. of the current LookAndFeel to use it for some custom Button-Drawing?

Martin Weber
  • 3,892
  • 4
  • 20
  • 23
  • What do you mean by "...JRadioButton always have that Dot"? – Stefan Apr 26 '13 at 18:25
  • I mean the Dot that shows if the Button is selected or not. – Martin Weber Apr 27 '13 at 06:04
  • Hm I don't get the question. Why don't you add JRadioButtons to a ButtonGroup, so only the last one clicked will be selected? – Stefan Apr 27 '13 at 15:50
  • I do that, actually that's the reason i used JRadioButton's in the first place. The problem is that i want to use icons to display the buttons and make them look like JButtons, but Radiobuttons always have that "RadioDot"(?) so i have to draw it myself. – Martin Weber Apr 28 '13 at 12:58

1 Answers1

1

So how can i read Background-Colors etc. of the current LookAndFeel to use it for some custom Button-Drawing?

See UIManager Defaults.

I need to draw them myself by overriding the paint-methods

Don't do custom painting in the component. If you don't like the default Icons, then create your own Icon and do the custom painting there or create an Image and use an ImageIcon. The you can use the setXXXIcon() methods.

camickr
  • 321,443
  • 19
  • 166
  • 288