JButton
The JButton class displays a clickable button component with the text you specify:
JButton button = new JButton("Please click me");
panel.add(button);
The above code result in:.
Note that although you can click on the button and it gives the visual feedback of being pressed and released, nothing actually happens until you attach a listener object to the button, so it knows what action to perform. You saw how to do this in Section 13.
Comments