FileDocCategorySizeDatePackage
SwingDemo.javaAPI DocExample2768Fri Dec 07 10:10:50 GMT 2001None

SwingDemo

public class SwingDemo extends JFrame

Fields Summary
private JTextField
textfield
private JTabbedPane
tabbedPane
Constructors Summary
public SwingDemo()

		super("Swing Demo");
		setSize(540,420);
		addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e)
			{
				System.exit(0);
			}
		});
		// Textfield at South is for status messages. 
		// The JComponents use it to report events
		textfield=new JTextField();
		getContentPane().add(textfield,BorderLayout.SOUTH);

		// tabbed pane contains panels for the JComponents
		tabbedPane = new JTabbedPane();
		populateTabbedPane();
		getContentPane().add(tabbedPane,BorderLayout.CENTER);
		addMenu();
	
Methods Summary
private voidaddMenu()

		JMenuBar mbar = new JMenuBar();
		JMenu menu = new JMenu("File");
		menu.add(new JCheckBoxMenuItem("Check me"));
		menu.addSeparator();
		JMenuItem item = new JMenuItem("Exit");
		item.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e)
			{
				System.exit(0);
			}
		});
		menu.add(item);
		mbar.add(menu);
		setJMenuBar(mbar);
	
public static voidmain(java.lang.String[] args)

		SwingDemo that = new SwingDemo();
		that.setVisible(true);
	
private voidpopulateTabbedPane()

		tabbedPane.addTab("Button", 
			new TabIcon(),
			new ButtonPanel(textfield),
			"Click here for button demo");
		tabbedPane.addTab("Label", 
			null,
			new LabelPanel(),
			"Click here for Label demo");
		tabbedPane.addTab("Toggles", 
			null,
			new TogglePanel(textfield),
			"Click here for Toggle demo");
		tabbedPane.addTab("Combo Box", 
			null,
			new ComboPanel(textfield),
			"Click here for Combo Box demo");
		tabbedPane.addTab("Sliders", 
			null,
			new SliderPanel(textfield),
			"Click here for Slider demo");
		tabbedPane.addTab("Password", 
			null,
			new PasswordPanel(),
			"Click here for Password demo");
		tabbedPane.addTab("Toolbar", 
			null,
			new ToolbarPanel(),
			"Click here for Toolbar demo");
		tabbedPane.addTab("Table", 
			null,
			new TablePanel(),
			"Click here for Table demo");