Basic HTML version of Foils prepared July 6 99

Foil 41 Basic components

From Use of Java Language in Computational Science DoD Modernization Users Group Conference Monterey -- June 7 99. by Nancy McCracken, Geoffrey C. Fox


1 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);
2 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();
3 Click here
4 Initial text

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Jul 6 1999