Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.eclipse.swt.snippets;
- import org.eclipse.swt.widgets.Display;
- import org.eclipse.swt.widgets.Shell;
- import org.eclipse.swt.widgets.Text;
- import org.eclipse.swt.SWT;
- public class GUI {
- protected Shell shell;
- private Text text;
- /**
- * Launch the application.
- *
- * @param args
- */
- public GUI() {
- Thread thread = new Thread(){
- public void run(){
- try {
- open();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- };
- thread.start();
- }
- /**
- * Open the window.
- */
- public void open() {
- Display display = Display.getDefault();
- createContents();
- shell.open();
- shell.layout();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch()) {
- display.sleep();
- }
- }
- }
- /**
- * Create contents of the window.
- */
- protected void createContents() {
- shell = new Shell();
- shell.setSize(450, 300);
- shell.setText("SWT Application");
- text = new Text(shell, SWT.BORDER);
- text.setBounds(180, 122, 188, 107);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement