This is one of the simplest components. The component labeled ''Add to Cart," in Figure 1, is an example of a button. To create a button, first declare the button object to be of type JButton. For example,
JButton cartbutton;
Then invoke the javax.swing.JButton constructor, as follows:
cartbutton = new JButton(''Add to Cart");
This will create a button labeled with the supplied text. It is possible to create an unlabeled button using the constructor JButton(). All the layout examples in Section 8.5 also use buttons.
How to create a Button in Java
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment