private void createDialog(Shell applicationShell) { if (dialog == null || dialog.isDisposed()) { dialog = new Shell(applicationShell, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL); if (applicationShell.getImage() != null) { dialog.setImage(applicationShell.getImage()); } dialog.addListener( SWT.Close, new Listener() { public void handleEvent(Event event) { hideCustomPanelChildren(); } }); dialog.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent arg0) { disposeImages(); } }); if (fileDialogMode != VFS_DIALOG_SAVEAS) { dialog.setText(Messages.getString("VfsFileChooserDialog.openFile")); // $NON-NLS-1$ } else { dialog.setText(Messages.getString("VfsFileChooserDialog.saveAs")); // $NON-NLS-1$ } dialog.setLayout(new GridLayout()); dialog.setBackgroundMode(SWT.INHERIT_FORCE); dialog.setBackground(dialog.getDisplay().getSystemColor(SWT.COLOR_WHITE)); createCustomUIPanel(dialog); } }
public SwtWindow(Element self, XulComponent parent, XulDomContainer container, String tagName) { super(tagName); Shell possibleParent = null; orient = Orient.VERTICAL; if (container.getOuterContext() != null && container.getOuterContext() instanceof Shell && (self != null && self.getAttributeValue("proxyoutercontext") != null)) { shell = (Shell) container.getOuterContext(); } else { // First, check to see if an outer context was passed before parser started... if (container.getOuterContext() != null && container.getOuterContext() instanceof Shell) { possibleParent = (Shell) container.getOuterContext(); } // If not, then try to use the API's parent parameter... if ((possibleParent == null) && (parent != null)) { possibleParent = (Shell) parent.getManagedObject(); } // Otherwise, you're on your own... shell = (possibleParent != null) ? new Shell(possibleParent, SWT.SHELL_TRIM) : new Shell(SWT.SHELL_TRIM); } shell.setLayout(new GridLayout()); shell.setBackgroundMode(SWT.INHERIT_DEFAULT); setManagedObject(shell); xulDomContainer = container; }
private Shell getLimboShell() { if (limbo == null) { limbo = new Shell(Display.getCurrent(), SWT.NONE); // Place the limbo shell 'off screen' limbo.setLocation(0, 10000); limbo.setBackgroundMode(SWT.INHERIT_DEFAULT); limbo.setData(ShellActivationListener.DIALOG_IGNORE_KEY, Boolean.TRUE); } return limbo; }
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); // Set the shell background to something different shell.setBackground(display.getSystemColor(SWT.COLOR_RED)); // Tell the shell to give its children the same background color or image shell.setBackgroundMode(SWT.INHERIT_DEFAULT); // Optionally trying creating a patterned image for the shell background // final Image backImage = new Image(display,10,10); // GC gc = new GC(backImage); // gc.drawLine(0,0,9,9); // gc.dispose(); // shell.addDisposeListener(new DisposeListener() { // public void widgetDisposed(DisposeEvent e) { // backImage.dispose(); // } // }); // shell.setBackgroundImage(backImage); PGroup group = new PGroup(shell, SWT.SMOOTH); group.setText("Example"); group.setLayout(new FillLayout()); group.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); Composite groupClient = new Composite(group, SWT.NONE); groupClient.setBackground(display.getSystemColor(SWT.COLOR_WHITE)); groupClient.setLayout(new GridLayout()); Label label = new Label(groupClient, SWT.NONE); label.setText("Contents"); Button button = new Button(groupClient, SWT.PUSH); button.setText("Contents"); Scale scale = new Scale(groupClient, SWT.HORIZONTAL); shell.setSize(200, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
/** * Auto-generated main method to display this org.eclipse.swt.widgets.Composite inside a new * Shell. */ public static void main(String[] args) { display = Display.getDefault(); Shell shell = new Shell(display, SWT.NO_TRIM); shell.setBackgroundMode(SWT.INHERIT_DEFAULT); UI inst = new UI(shell, SWT.NULL); Point size = inst.getSize(); shell.setLayout(new FillLayout()); shell.layout(); if (size.x == 0 && size.y == 0) { inst.pack(); shell.pack(); } else { Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y); shell.setSize(shellBounds.width, shellBounds.height); } shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // display.sleep(); inst.update(); } } }
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(); } }