Basic components
For each basic component, one can create one or more instances of the component type and then use one of the "add" methods to place it into a Container such as an applet window.
- Button button1 = new Button("Click here");
- add (button1);
- TextField tf = new TextField(Iinitial text", 30);
- add(tf);
For each basic component, additional methods allow access to the properties of the components:
- button1.setBackground (Color.cyan);
- text which is displayed can be changed:
- tf.setText("now show a new text");
- If the user types input into the text field, it can be obtained:
- stringvar = tf.getText();