Buttons in shapes other than rectangles
3 answers
You can create buttons like this by extending the JButton and calling setContentAreaFilled(false);
in the constructor. Then you can draw whatever you like in the overridden method paintComponent()
. You also need to override the method contains()
JComponent
to provide the required mouse hit test. In this method, you can call the polygon (the one used to draw the button) contains()
.
+2
source to share