FileDocCategorySizeDatePackage
SwingAWTClass.javaAPI DocExample1200Tue Mar 09 12:56:06 GMT 2004org.cookbook.ch09

SwingAWTClass

public class SwingAWTClass extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		final Display display = new Display();
		final Shell shell = new Shell(display);
		shell.setText("Using Swing and AWT");
		shell.setSize(350, 280);
		
		Composite composite = new Composite(shell, SWT.EMBEDDED);
		composite.setBounds(20, 20, 300, 200);
		composite.setLayout(new RowLayout());

		java.awt.Frame frame = SWT_AWT.new_Frame(composite);
		java.awt.Panel panel = new java.awt.Panel();
		frame.add(panel);

	    final javax.swing.JButton button = new javax.swing.JButton("Click Me");
	    final javax.swing.JTextField text = new javax.swing.JTextField(20);

	    panel.add(button);
	    panel.add(text);

		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				text.setText("Yep, it works.");
			}
		});
	    
		shell.open();
		while(!shell.isDisposed()) {
			if (!display.readAndDispatch()) display.sleep();
		}
		display.dispose();