I'd like to change the appearance of a button when it's in pressed/clicked/selected state.
To be more specific, I'd like to change it's border to BorderFactory.createLoweredBevelBorder()
when it' is pressed/clicked/selected.
How can I do this?
I'd like to change the appearance of a button when it's in pressed/clicked/selected state.
To be more specific, I'd like to change it's border to BorderFactory.createLoweredBevelBorder()
when it' is pressed/clicked/selected.
How can I do this?
Please see the code below. It sets the border when pressed and resets it when released. You can also do this on mouseEntered
/ mouseExited
.
button.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
button.setBorder(BorderFactory.createLoweredBevelBorder());
}
public void mouseReleased(MouseEvent e) {
button.setBorder(null);
}
});