Create a JButton that does not show focus in Java
Description
The following code shows how to create a JButton that does not show focus.
Example
//from ww w. j av a2 s . co m
import javax.swing.JButton;
import javax.swing.JFrame;
public class Main extends JFrame {
public Main() {
setSize(300, 150);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JButton button = new JButton("java2s.com");
button.setFocusPainted(false);
button.setContentAreaFilled(false);
add(button);
setVisible(true);
}
public static void main(String[] args) {
new Main();
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »