public static void main(String[] args) { Display display = Display.getDefault(); Shell shell = new Shell(display); @SuppressWarnings("unused") MainWindow inst = new MainWindow(shell, SWT.NULL); shell.setLayout(new FillLayout()); shell.setImage(SWTResourceManager.getImage("images/16x16.png")); shell.setText("Change This Title"); shell.setBackgroundImage(SWTResourceManager.getImage("images/ToolbarBackground.gif")); shell.layout(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }
public void open() { final Shell parent = getParent(); dialogShell = new Shell(parent, SWT.CLOSE | SWT.TITLE | SWT.APPLICATION_MODAL); com.cloudgarden.resource.SWTResourceManager.registerResourceUser(dialogShell); closeListener = new CloseShellListener(dialogShell); dialogShell.addListener(SWT.Close, closeListener); dialogShell.layout(); dialogShell.pack(); dialogShell.setText("TwoCents Wizard"); dialogShell.setSize(394, 596); dialogShell.setLocation(300, 200); dialogShell.setLocation(getParent().toDisplay(100, 100)); // int positionX=parent.getBounds().x+(parent.getBounds().width /4); // Move the dialog to the center of the top level shell. Rectangle shellBounds = getParent().getBounds(); Point dialogSize = dialogShell.getSize(); dialogShell.setLocation( shellBounds.x + (shellBounds.width - dialogSize.x) / 2, shellBounds.y + (shellBounds.height - dialogSize.y) / 2); dialogShell.setBackgroundImage( SWTResourceManager.getImage( TwWizard.class, UIDefault.COM_TWOCENTS_UI_RESOURCES_IMAGES_LOGIN_SCREEN_PNG)); dialogShell.setBackgroundMode(SWT.INHERIT_DEFAULT); createWizardNoticeScreen(dialogShell); Label lblNewLabel_3 = new Label(dialogShell, SWT.NONE); lblNewLabel_3.setFont( org.eclipse.wb.swt.SWTResourceManager.getFont("Segoe UI", 10, SWT.NORMAL)); lblNewLabel_3.setForeground(org.eclipse.wb.swt.SWTResourceManager.getColor(SWT.COLOR_WHITE)); lblNewLabel_3.setText("Informa\u00E7\u00F5es sobre corretora :"); Group groupBroker = new Group(dialogShell, SWT.NONE); groupBroker.setForeground(org.eclipse.wb.swt.SWTResourceManager.getColor(SWT.COLOR_WHITE)); groupBroker.setLayout(new GridLayout(2, false)); groupBroker.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); Label lblNewLabel_1 = new Label(groupBroker, SWT.NONE); lblNewLabel_1.setForeground(org.eclipse.wb.swt.SWTResourceManager.getColor(SWT.COLOR_WHITE)); lblNewLabel_1.setFont( org.eclipse.wb.swt.SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL)); lblNewLabel_1.setText("Nome :"); txtCorretora = new Text(groupBroker, SWT.BORDER); txtCorretora.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblNewLabel_2 = new Label(groupBroker, SWT.NONE); lblNewLabel_2.setForeground(org.eclipse.wb.swt.SWTResourceManager.getColor(SWT.COLOR_WHITE)); lblNewLabel_2.setFont( org.eclipse.wb.swt.SWTResourceManager.getFont("Segoe UI", 12, SWT.NORMAL)); lblNewLabel_2.setText("Corretagem :"); txtFixa = new Text(groupBroker, SWT.BORDER); txtFixa.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(dialogShell, SWT.NONE); final Button nextBtn = new Button(dialogShell, SWT.NONE); nextBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); nextBtn.setText("Cadastrar"); nextBtn.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent arg0) { try { fillAndRegisterStockBroker(); Broker broker = new Broker(); StockBroker stockBrokeradded = fillAndRegisterBroker(broker); TwUser user = new PopulateData() .populateUser( stockBrokeradded.getName(), stockBrokeradded.getPassword(), "", stockBrokeradded.getEmail(), stockBrokeradded.getTelefone()); new AccountFacade().addAccount(user, stockBrokeradded, broker.getName(), "1"); dialogShell.removeListener(SWT.Close, closeListener); dialogShell.close(); } catch (Exception e) { DialogUtil.errorMessage(dialogShell, e.getMessage(), e.getMessage()); } } }); dialogShell.open(); Display display = dialogShell.getDisplay(); while (!dialogShell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } }