1

I am just trying to have some of my JButtons to be painted fully orange in addition to the orange border when they have focus. Instead, setFocusPainted(true) turns out to only paint the border:

enter image description here

Many applications seem to use the full orange buttons for focus, but I struggle to find the correct solution for this in Java Swing.

I have no problems implementing my own custom JButtons or whatever. But I would think there should be a simple setting for this, because I shouldn't have to go and find out the RGB color values which Ubuntu uses so I can comply with native UI stuff.

I want this:

enter image description here

Pressing tab changes the JButton to its normal color as it loses focus.

I am obviously using the specific System's LAF. I used setFocusPainted(true) and all (otherwise the orange border wouldn't be there). It is also possible to get this when using MigLayouts specified buttons (okbutton etc.):

enter image description here

So what am I missing?

ChrisK
  • 158
  • 1
  • 13

1 Answers1

2

You may be looking for the setDefaultButton() method of JRootPane, shown here, in concert with the GTKLookAndFeel.

java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel …

image

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Bingo, this is it. Thank you very much. – ChrisK Jun 24 '15 at 19:56
  • @ChrisK: Glad it helped; the corresponding appearance is seen [here](http://stackoverflow.com/a/14947144/230513) in an earlier version of `com.apple.laf.AquaLookAndFeel`. – trashgod Jun 24 '15 at 22:23
  • Thanks, I have tested this on OSX and Windows as well and it's precisely what I was looking for. Guess I should have understood that this is Ubuntu's treatment of the root pane's "default button". I always thought it was just some specific focus highlighting. – ChrisK Jun 25 '15 at 10:41