Reputation: 653
I'm looking for a substitute of .setEnabled(false)
, so that the button is not clickable.
I have read that I could remove the ActionListener from the button, but I just want the specific buttons to be not clickable, and do not know how to do it anyway.
Or how can I get rid of the "selected" effect after clicking a button?
Upvotes: 3
Views: 20001
Reputation: 324197
Because in my application I have a grid of JButtons that are used as icons
Then don't use buttons, use a JLabel which also supports an Icon.
Or maybe use a JList which can also support a grid.
Or if you use a JButton then you need code like:
JButton button = new JButton(...);
button.setBorderPainted( false );
button.setFocusPainted( false );
Upvotes: 5
Reputation: 11740
I assume that the problem is how the button looks grayed out, because setEnabled
really is the way you disable a button - which just means making it not clickable (or did you want it to respond to keyboard input?). If that's the case, then you can change the way it looks by using html:
button.setText("<html><font color=black>3</font></html>");
Upvotes: 1