SWT study notes (3) - the first program

xiaoxiao2021-03-06  74

This program automatically generates with VE plugins, VE information is available http://blog.9cbs.net/happy1123/archive/2004/10/130395.aspx

Source code:

import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class SwtAppTest {private Shell sShell = null; // Shell corresponds to a Form for placing other components of private Button button = null; private label label = null; public static void main (String [] args) {/ * Before this is run, be sure to set up the following in the launch configuration * (Arguments . -> VM Arguments) for the correct SWT library path * The following is a windows example: * -Djava.library.path = "installation_directory / plugins / org.eclipse.swt.win32_3.0.0 / os / win32 / x86" * / Display display = Display.getDefault (); // Display responsible for the connection to the underlying operating system SwtAppTest thisClass = new SwtAppTest (); thisClass.createSShell (); thisClass.sShell.open ();! while (thisClass.sShell.isDisposed ( ))) {// loop waiting request if (! Display.readandDispatch ()) Display.sleep (); // If not requested, it is in Sleep State} Di SPLAY.DISPOSE (); // Don't forget to drop Display Dispose} / ** * this method initializes sshell * / private void createhell () {sshell = new shell (); button = new button (sshell, swT. None; label = new label; sshell.setsize (new point (300, 200)); sshell.settext ("shell"); button.setbounds (new org.eclipse.swt.graphics.Rectangle) 116, 116, 72, 22); Button.Settext ("exit"); label.settext ("Hello World!"); Label.setBounds (New Rectangle (117, 50, 72, 12));

button.addSelectionListener (new org.eclipse.swt.events.SelectionAdapter () {public void widgetSelected (org.eclipse.swt.events.SelectionEvent e) {System.exit (0);}});}} This is a Hello World.

转载请注明原文地址:https://www.9cbs.com/read-108595.html

New Post(0)