FileDocCategorySizeDatePackage
GUIwithFrame.javaAPI DocExample1092Tue Mar 13 22:36:12 GMT 2001None

GUIwithFrame

public class GUIwithFrame extends Object
Simple GUI demonstration: construct a Frame and populate it.
author
Ian F. Darwin, ian@darwinsys.com
version
#Id$

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] av)
"main" method

		Button quitButton;

		// create a GUIwithFrame object and make it show
		final Frame f = new Frame();
		f.setLayout(new FlowLayout());
		f.add(new Label("Hello, and welcome to the world of Java"));
		f.add(quitButton = new Button("Exit"));
		quitButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				f.setVisible(false);
				f.dispose();
				System.exit(0);
			}
		});

		// Set the Frame's windowListener to be a trivial WindowAdapter
		// subclass that just calls System.exit(). Not ideal but works here.
		// DO NOT USE THIS in any program that saves user input in memory!
		f.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
				return;
			}
		});
		f.add(new TextArea(24,80));
		f.pack();
		f.setVisible(true);