tags:

views:

75

answers:

3

This may be a silly question I don't know.

Is there a way to remove the highlighter to represent focus in a Java GUI?

For example when you click on a button the text will have a slight rectangle around the text.

Thank you

A: 

As far as I knew one of the selling points of swing when it first appeared was that any GUI element could be completely customised. This might help you out: Custom Swing Controls

Jason Edwards
+2  A: 

I believe you want to remove the set focusable attribute from your items

using setFocusable(false)

http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html

Holograham
Depends on the real requirement. If you set the button non focusable, then you can't tab to the button using the keyboard which means you can't "click" the button using the keyboard. If the button is in a toolbar, then maybe you would make it non focusable because toolbars buttons are generally invoked with the mouse. If you using other buttons on a dialog then the user should have the option to tab and use the keyboard.
camickr
Ok, good explanation. Though the question originator stated in a comment that this was for a touch screen interface so no keyboard.
Holograham
+2  A: 

That feature is there for a reason because it gives user feedback about which component currently has focus. But if you really must turn it off then you can use:

button.setFocusPainted( false );
camickr
both work :) Pick mine!
Holograham
This actually more correctly answers my question
Albinoswordfish