protected void openDialog() { if (Const.isWindows()) { shell.setSize(653, 671); } if (Const.isLinux()) { shell.setSize(740, 678); } if (Const.isOSX()) { shell.setSize(653, 678); } // Set the focus on the OK button wOK.setFocus(); shell.open(); Rectangle shellBounds = getParent().getBounds(); Point dialogSize = shell.getSize(); shell.setLocation( shellBounds.x + (shellBounds.width - dialogSize.x) / 2, shellBounds.y + (shellBounds.height - dialogSize.y) / 2); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } }
public InputViewer(Shell parent, Properties properties, String resources) { sShell = new org.eclipse.swt.widgets.Shell(parent); sShell.setLocation(parent.getLocation().x + 200, parent.getLocation().y + 150); sShell.setSize(new org.eclipse.swt.graphics.Point(471, 146)); sShell.setLayout(null); listeners = new Vector<DialogInputListener>(); ApplicationFactory factory = new ApplicationFactory(sShell, resources, getClass().getName()); factory.createLabel("lbl").setBounds(15, 15, 100, 20); txtName = factory.createText(); txtName.setBounds(120, 15, 280, 20); txtName.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.keyCode != 13) return; enter(); } }); factory .createButton( "but", new SelectionAdapter() { @SuppressWarnings("unused") public void widgetSelected(SelectionEvent e) { enter(); } }) .setBounds(180, 50, 90, 20); sShell.setSize(420, 120); sShell.open(); }
/** * This method initializes hyperLinkShell. * * @wbp.parser.entryPoint */ protected void createHyperLinkShell() { GridData gridData9 = new GridData(); gridData9.grabExcessHorizontalSpace = true; gridData9.verticalAlignment = GridData.FILL; gridData9.horizontalSpan = 2; gridData9.horizontalAlignment = GridData.FILL; GridData gridData8 = new GridData(); gridData8.horizontalAlignment = GridData.FILL; gridData8.grabExcessHorizontalSpace = true; gridData8.horizontalSpan = 2; gridData8.verticalAlignment = GridData.FILL; GridLayout gridLayout2 = new GridLayout(); gridLayout2.numColumns = 14; gridLayout2.makeColumnsEqualWidth = true; // this line has to be commented in order to open with VISUAL EDITOR hyperLinkShell = new Shell(PlatformUI.getWorkbench().getDisplay().getActiveShell()); // hyperLinkShell = new Shell(); hyperLinkShell.setText(Messages.AbstractHyperLinkManagerShell_HyperLink); hyperLinkShell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); createCTabFolder(); hyperLinkShell.setLayout(gridLayout2); hyperLinkShell.setSize(new Point(687, 308)); OkButton = new Button(hyperLinkShell, SWT.NONE); OkButton.setText(Messages.AbstractHyperLinkManagerShell_OK); OkButton.setLayoutData(gridData9); cancelButton = new Button(hyperLinkShell, SWT.NONE); cancelButton.setText(Messages.AbstractHyperLinkManagerShell_Cancel); cancelButton.setLayoutData(gridData8); }
/** Create contents of the window. */ protected void createContents() { mAndroidSdkUpdater = new Shell(mParentShell, SWT.SHELL_TRIM); mAndroidSdkUpdater.addDisposeListener( new DisposeListener() { public void widgetDisposed(DisposeEvent e) { onAndroidSdkUpdaterDispose(); // $hide$ (hide from SWT designer) } }); FillLayout fl; mAndroidSdkUpdater.setLayout(fl = new FillLayout(SWT.HORIZONTAL)); fl.marginHeight = fl.marginWidth = 5; mAndroidSdkUpdater.setMinimumSize(new Point(200, 50)); mAndroidSdkUpdater.setSize(745, 433); mAndroidSdkUpdater.setText("Android SDK and AVD Manager"); mSashForm = new SashForm(mAndroidSdkUpdater, SWT.NONE); mPageList = new List(mSashForm, SWT.BORDER); mPageList.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onPageListSelected(); // $hide$ (hide from SWT designer) } }); mPagesRootComposite = new Composite(mSashForm, SWT.NONE); mStackLayout = new StackLayout(); mPagesRootComposite.setLayout(mStackLayout); createPages(); mSashForm.setWeights(new int[] {150, 576}); }
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(); LightweightSystem lws = new LightweightSystem(shell); Figure panel = new Figure(); panel.setLayoutManager(new FlowLayout()); panel.setBackgroundColor(ColorConstants.white); MouseMotionListener listener = new MouseMotionListener.Stub() { public void mouseEntered(MouseEvent me) { ((Shape) me.getSource()).setBackgroundColor(ColorConstants.yellow); } public void mouseExited(MouseEvent me) { ((Shape) me.getSource()).setBackgroundColor(ColorConstants.white); } }; for (int i = 1; i <= 4; i++) { Ellipse e = new Ellipse(); e.setFill(true); e.setPreferredSize(new Dimension(20 + 10 * i + i % 2, 60 - 10 * i + i / 2)); e.addMouseMotionListener(listener); panel.add(e); } lws.setContents(panel); shell.setSize(400, 300); shell.open(); while (!shell.isDisposed()) if (!display.readAndDispatch()) display.sleep(); }
public void run(String trace) throws JDOMException, IOException, JniException { Display display = new Display(); Shell shell = new Shell(display); shell.setText("Flightbox"); shell.setSize(800, 800); shell.setLayout(new FillLayout(SWT.VERTICAL)); IntervalView widget = new IntervalView(shell, SWT.NONE); VersionizedStack<String> stack = new VersionizedStack<String>(); int i; int max = 1000; for (i = 0; i < max; i++) { long disp = i * 100; stack.push("FOO", 10L + disp); stack.push("BAR", 20L + disp); stack.pop(30L + disp); stack.pop(40L + disp); } widget.setStack(stack); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } shell.dispose(); }
public void buildView(List<String> files) { this.files = files; display = new Display(); shell = new Shell(display); shell.setText("Ebook converter"); shell.setSize(300, 400); list = new org.eclipse.swt.widgets.List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); list.setBounds(40, 20, 220, 100); label = new Label(shell, SWT.BORDER); label.setBounds(60, 130, 160, 25); label.setText("Converted:"); listConverted = new org.eclipse.swt.widgets.List(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); listConverted.setBounds(40, 170, 220, 100); updateList(); list.addListener(SWT.DefaultSelection, this); listConverted.addListener( SWT.DefaultSelection, new Listener() { public void handleEvent(Event event) { try { int i = listConverted.getSelectionIndices()[0]; System.err.println(i); Runtime.getRuntime().exec(pdfViewer + " " + listConverted.getItem(i)); } catch (IOException e) { e.printStackTrace(); } } }); }
public static void main(String[] args) { Display d = new Display(); Shell shell = new Shell(d); shell.setText("GraphSnippet1"); shell.setLayout(new FillLayout()); shell.setSize(400, 400); final Graph g = new Graph(shell, SWT.NONE); hookMenu(g); SpaceTreeLayoutAlgorithm spaceTreeLayoutAlgorithm = new SpaceTreeLayoutAlgorithm(); g.setLayoutAlgorithm(spaceTreeLayoutAlgorithm, false); g.setExpandCollapseManager(spaceTreeLayoutAlgorithm.getExpandCollapseManager()); g.setSubgraphFactory(new DefaultSubgraph.LabelSubgraphFactory()); for (int i = 0; i < 20; i++) { GraphNode graphNode = new GraphNode(g, SWT.NONE); graphNode.setText("" + i); } shell.open(); while (!shell.isDisposed()) { while (!d.readAndDispatch()) { d.sleep(); } } }
/** Create contents of the dialog. */ private void createContents() { shell = new Shell(getParent()); shell.setSize(334, 100); shell.setText(getText()); shell.setLayout(new GridLayout(2, false)); combo = new Combo(shell, SWT.READ_ONLY); combo.setItems(options); combo.select(0); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); Button btnNewButton = new Button(shell, SWT.NONE); btnNewButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = combo.getText(); shell.close(); } }); btnNewButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); btnNewButton.setText("Select"); Button btnNewButton_1 = new Button(shell, SWT.NONE); btnNewButton_1.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { result = null; shell.close(); } }); btnNewButton_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnNewButton_1.setText("Cancel"); }
/** Debug only */ private static void drawModel(final SWTArranger a) { final Display d = new Display(); Shell s = new Shell(d); s.setSize(500, 500); s.setLayout(new FillLayout()); Canvas canvas = new Canvas(s, SWT.NONE); canvas.setSize(500, 500); canvas.setLocation(20, 20); canvas.addPaintListener( new PaintListener() { @Override public void paintControl(PaintEvent e) { Color c = new Color(d, 0x00, 0x00, 0x00); GC gc = e.gc; gc.setBackground(c); for (Block r : a.blocks) { gc.fillRectangle(r.x, r.y, r.width, r.height); } c.dispose(); gc.dispose(); } }); s.pack(); s.open(); while (!s.isDisposed()) { if (!d.readAndDispatch()) { d.sleep(); } } d.dispose(); }
@Test public void testRedraw() { final Table[] table = {null}; shell.setSize(100, 100); Button button = new Button(shell, SWT.PUSH); getRemoteObject(button).setHandler(new ButtonOperationHandler(button)); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { table[0] = new Table(shell, SWT.VIRTUAL); table[0].setItemCount(500); table[0].setSize(90, 90); assertFalse(isItemVirtual(table[0], 0)); table[0].clearAll(); table[0].redraw(); } }); shell.open(); Fixture.fakeNotifyOperation(getId(button), ClientMessageConst.EVENT_SELECTION, null); Fixture.readDataAndProcessAction(display); assertFalse(isItemVirtual(table[0], 0)); }
@Test public void testSetDataEvent() { shell.setSize(100, 100); table = new Table(shell, SWT.VIRTUAL); Fixture.markInitialized(table); getRemoteObject(table).setHandler(new TableOperationHandler(table)); Listener listener = new Listener() { @Override public void handleEvent(Event event) { Item item = (Item) event.item; item.setText("Item " + event.index); } }; table.addListener(SWT.SetData, listener); table.setSize(90, 90); table.setItemCount(1000); shell.layout(); shell.open(); assertTrue(isItemVirtual(table, 500)); // ensure precondition fakeSetTopItemIndex(table, 500); Fixture.executeLifeCycleFromServerThread(); // Remove SetData listener to not accidentially resolve item with asserts table.removeListener(SWT.SetData, listener); assertFalse(isItemVirtual(table, 500)); assertFalse(isItemVirtual(table, 502)); assertTrue(isItemVirtual(table, 510)); assertEquals("Item 500", table.getItem(500).getText()); assertEquals("Item 502", table.getItem(502).getText()); }
public static void main(String[] args) { Display d = new Display(); final Shell shell = new Shell(d); shell.setText("Hello world"); shell.setSize(600, 400); shell.setLayout(new FillLayout()); Text text = new Text(shell, SWT.BORDER); text.setBounds(40, 40, 100, 20); Button b = new Button(shell, SWT.PUSH); b.setText("Click me!"); b.setLocation(200, 200); b.setSize(50, 50); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Button b = new Button(shell, SWT.PUSH); b.setText("New button"); Random r = new Random(); b.setBounds(r.nextInt(600), r.nextInt(400), 100, 100); shell.layout(true); } }); shell.open(); while (!shell.isDisposed()) { if (!d.readAndDispatch()) d.sleep(); } }
public static void main(String[] args) { // Create the shell Display d = new Display(); Shell shell = new Shell(d); shell.setText("GraphSnippet1"); shell.setLayout(new FillLayout()); shell.setSize(500, 500); final Graph g = new Graph(shell, SWT.NONE); g.setSize(500, 500); GraphNode root = new GraphNode(g, SWT.NONE, "Root"); for (int i = 0; i < 3; i++) { GraphNode n = new GraphNode(g, SWT.NONE, "1 - " + i); for (int j = 0; j < 3; j++) { GraphNode n2 = new GraphNode(g, SWT.NONE, "2 - " + j); new GraphConnection(g, SWT.NONE, n, n2).setWeight(-1); } new GraphConnection(g, SWT.NONE, root, n); } final LayoutAlgorithm layoutAlgorithm = new RadialLayoutAlgorithm(); g.setLayoutAlgorithm(layoutAlgorithm, true); shell.open(); while (!shell.isDisposed()) { while (!d.readAndDispatch()) { d.sleep(); } } }
@SuppressWarnings("unused") public Object execute(ExecutionEvent event) throws ExecutionException { final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); if (window == null) { return null; } final IContextService service = (IContextService) window.getService(IContextService.class); Shell shell = new Shell(window.getShell().getDisplay()); service.registerShell(shell, IContextService.TYPE_WINDOW); // Shell shell = new Shell(window.getShell()); shell.setLayout(new FillLayout()); Button b = new Button(shell, SWT.PUSH); final Text text = new Text(shell, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); b.setText(Messages.showContexts_button); b.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Object[] array = service.getActiveContextIds().toArray(); Arrays.sort(array); StringBuffer buf = new StringBuffer(Messages.showContexts_title); for (int i = 0; i < array.length; i++) { buf.append('\n'); buf.append(array[i].toString()); } text.setText(buf.toString()); } }); shell.setSize(400, 300); shell.layout(); shell.open(); return null; }
/** * {@inheritDoc} * * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) */ @Override protected void configureShell(Shell newShell) { super.configureShell(newShell); newShell.setText( DocBridgeUI.getInstance().getString("DocumentationLinkDialog_title")); // $NON-NLS-1$ newShell.setSize(450, 520); }
public Shell createShell() { // Build a UI Display display = Display.getDefault(); Shell shell = new Shell(display); duckFamily = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION); duckFamily.setHeaderVisible(true); GridDataFactory.defaultsFor(duckFamily).span(2, 1).applyTo(duckFamily); createColumn("Name"); createColumn("Mother"); createColumn("Father"); createColumn("Grandmother"); duckFamily.setLinesVisible(true); new Label(shell, SWT.NONE).setText("Name:"); nameText = new Text(shell, SWT.BORDER); GridDataFactory.defaultsFor(nameText).grab(true, false).applyTo(nameText); new Label(shell, SWT.NONE).setText("Mother:"); motherCombo = new Combo(shell, SWT.READ_ONLY); new Label(shell, SWT.NONE).setText("Father:"); fatherCombo = new Combo(shell, SWT.READ_ONLY); DataBindingContext bindingContext = new DataBindingContext(); bindGUI(bindingContext); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(shell); // Open and return the Shell shell.setSize(500, 300); shell.open(); return shell; }
/** Create contents of the window. */ protected void createContents() { shell = new Shell(SWT.NO_TRIM | SWT.BORDER); shell.setSize(850, 560); shell.setLayout(new FillLayout(SWT.HORIZONTAL)); LayoutUtil.centerShell(Display.getCurrent(), shell); Composite composite = new Composite(shell, SWT.NONE); composite.setBackgroundImage(SWTResourceManager.getImage(getClass(), "/res/bg.jpg")); composite.setBackgroundMode(SWT.INHERIT_FORCE); RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL); rowLayout.marginTop = 0; rowLayout.marginRight = 0; rowLayout.marginLeft = 0; rowLayout.spacing = 5; composite.setLayout(rowLayout); winTitle = createWinTitle(composite); winToolbar = createWinToolBar(composite); Composite winMainContent = new Composite(composite, SWT.NONE); winMainContent.setLayout(new StackLayout()); winMainContent.setLayoutData(new RowData(850, 407)); winStatusbar = createWinStatusBar(composite); addShellListener(winTitle, winToolbar, winStatusbar); }
/** This method initializes lookforShell. */ protected void createLookforShell() { GridData gridData2 = new GridData(); gridData2.horizontalAlignment = GridData.FILL; gridData2.verticalAlignment = GridData.CENTER; GridData gridData1 = new GridData(); gridData1.grabExcessHorizontalSpace = false; gridData1.horizontalAlignment = GridData.FILL; gridData1.verticalAlignment = GridData.CENTER; gridData1.grabExcessVerticalSpace = false; GridLayout gridLayout1 = new GridLayout(); gridLayout1.numColumns = 5; gridLayout1.makeColumnsEqualWidth = true; // this line has to be commented in order to open with VISUAL EDITOR lookforShell = new Shell(PlatformUI.getWorkbench().getDisplay().getActiveShell()); // lookforShell = new Shell(); lookforShell.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); createCTabFolder(); lookforShell.setLayout(gridLayout1); lookforShell.setSize(new Point(501, 313)); new Label(lookforShell, SWT.NONE); new Label(lookforShell, SWT.NONE); new Label(lookforShell, SWT.NONE); OKbutton = new Button(lookforShell, SWT.NONE); OKbutton.setText(Messages.AbstractLookForEditorShell_OK); OKbutton.setLayoutData(gridData1); OKbutton.setEnabled(false); cancelbutton = new Button(lookforShell, SWT.NONE); cancelbutton.setText(Messages.AbstractLookForEditorShell_Cancel); cancelbutton.setLayoutData(gridData2); }
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT and Swing DND Example"); GridLayout layout = new GridLayout(1, false); shell.setLayout(layout); Text swtText = new Text(shell, SWT.BORDER); swtText.setText("SWT Text"); GridData data = new GridData(GridData.FILL_HORIZONTAL); swtText.setLayoutData(data); setDragDrop(swtText); Composite comp = new Composite(shell, SWT.EMBEDDED); java.awt.Frame frame = SWT_AWT.new_Frame(comp); JTextField swingText = new JTextField(40); swingText.setText("Swing Text"); swingText.setDragEnabled(true); frame.add(swingText); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = swingText.getPreferredSize().height; comp.setLayoutData(data); shell.setSize(400, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER); styledText.setText(text); FontData data = display.getSystemFont().getFontData()[0]; Font font = new Font(display, data.getName(), 16, SWT.BOLD); styledText.setFont(font); styledText.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); styledText.addListener( SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle rect = styledText.getClientArea(); Image newImage = new Image(display, 1, Math.max(1, rect.height)); GC gc = new GC(newImage); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW)); gc.fillGradientRectangle(rect.x, rect.y, 1, rect.height, true); gc.dispose(); styledText.setBackgroundImage(newImage); if (oldImage != null) oldImage.dispose(); oldImage = newImage; } }); shell.setSize(700, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (oldImage != null) oldImage.dispose(); font.dispose(); display.dispose(); }
@Override protected void configureShell(Shell newShell) { newShell.setText(title); newShell.setSize(250, 250); super.configureShell(newShell); }
/** * Sets the size of the shell to it's "packed" size, unless that makes it bigger than the display, * in which case set it to 9/10 of display size. */ private static void setShellSize(Display display, Shell shell) { Rectangle bounds = display.getBounds(); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); if (size.x > bounds.width) size.x = bounds.width * 9 / 10; if (size.y > bounds.height) size.y = bounds.height * 9 / 10; shell.setSize(size); }
public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); final ScrolledComposite sc = new ScrolledComposite(shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); Composite c = new Composite(sc, SWT.NONE); c.setLayout(new GridLayout(10, true)); for (int i = 0; i < 300; i++) { Button b = new Button(c, SWT.PUSH); b.setText("Button " + i); } sc.setContent(c); sc.setExpandHorizontal(true); sc.setExpandVertical(true); sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setShowFocusedControl(true); shell.setSize(300, 500); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
protected void runTestAGL(GLProfile glprofile) throws InterruptedException { GLData gldata = new GLData(); gldata.doubleBuffer = true; // need SWT.NO_BACKGROUND to prevent SWT from clearing the window // at the wrong times (we use glClear for this instead) final GLCanvas glcanvas = new GLCanvas(composite, SWT.NO_BACKGROUND, gldata); Assert.assertNotNull(glcanvas); glcanvas.setCurrent(); final GLContext glcontext = GLDrawableFactory.getFactory(glprofile).createExternalGLContext(); Assert.assertNotNull(glcontext); // fix the viewport when the user resizes the window glcanvas.addListener( SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle rectangle = glcanvas.getClientArea(); glcanvas.setCurrent(); glcontext.makeCurrent(); GL2ES1 gl = glcontext.getGL().getGL2ES1(); OneTriangle.setup(gl, rectangle.width, rectangle.height); glcontext.release(); System.err.println("resize"); } }); // draw the triangle when the OS tells us that any part of the window needs drawing glcanvas.addPaintListener( new PaintListener() { public void paintControl(PaintEvent paintevent) { Rectangle rectangle = glcanvas.getClientArea(); glcanvas.setCurrent(); glcontext.makeCurrent(); GL2ES1 gl = glcontext.getGL().getGL2ES1(); OneTriangle.render(gl, rectangle.width, rectangle.height); glcanvas.swapBuffers(); glcontext.release(); System.err.println("paint"); } }); shell.setText(getClass().getName()); shell.setSize(640, 480); shell.open(); long lStartTime = System.currentTimeMillis(); long lEndTime = lStartTime + duration; try { while ((System.currentTimeMillis() < lEndTime) && !glcanvas.isDisposed()) { if (!display.readAndDispatch()) { // blocks on linux .. display.sleep(); Thread.sleep(10); } } } catch (Throwable throwable) { throwable.printStackTrace(); Assume.assumeNoException(throwable); } glcanvas.dispose(); }
/** * Sets the size for the dialog based on its previous size. The width of the dialog is its * previous width, if it exists. Otherwise, it is simply the packed width of the dialog. The * maximum width is 40% of the workbench window's width. The dialog's height is the packed height * of the dialog to a maximum of half the height of the workbench window. * * @return The size of the dialog */ private final Point configureSize() { final Shell shell = getShell(); // Get the packed size of the shell. shell.pack(); final Point size = shell.getSize(); // Enforce maximum sizing. final Shell workbenchWindowShell = EditorUtils.getShell(); if (workbenchWindowShell != null) { final Point workbenchWindowSize = workbenchWindowShell.getSize(); final int maxWidth = workbenchWindowSize.x * 2 / 5; final int maxHeight = workbenchWindowSize.y / 2; if (size.x > maxWidth) { size.x = maxWidth; } if (size.y > maxHeight) { size.y = maxHeight; } } // Set the size for the shell. shell.setSize(size); return size; }
private static void main() throws FileNotFoundException { // デフォルトDisplayを使用してシェルを作成 try { shell.setSize(100, 100); // シェルのサイズを指定 // 作成したシェルを使用したLightweightSystemの作成 LightweightSystem lws = new LightweightSystem(shell); // ルート・フィギュアの作成 IFigure panel = new Figure(); panel.setLayoutManager(new ToolbarLayout()); initialize(panel); // ルート・フィギュアの登録 lws.setContents(panel); // 以下は、その他のSWTアプリケーションと同様 shell.open(); Display display = Display.getDefault(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } } finally { if (image != null) { image.dispose(); } } }
public static void main(final String[] args) { final Display display = Display.getDefault(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final CompositeTable table = new CompositeTable(shell, SWT.NONE); new Header(table, SWT.NONE); new Row(table, SWT.NONE); table.setRunTime(true); final ICompositeTableRidget ridget = (ICompositeTableRidget) SwtRidgetFactory.createRidget(table); final WritableList input = new WritableList(PersonFactory.createPersonList(), Person.class); ridget.bindToModel(input, Person.class, RowRidget.class); ridget.updateFromModel(); shell.setSize(400, 160); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
private void open() { display = Display.getDefault(); shell = new Shell(); shell.setSize(250, 170); // ---------创建窗口中的其他界面组件------------- shell.setLayout(new GridLayout()); createMainComp(shell); // 创建主面板 createStatusbar(shell); // 创建工具栏 // -----------------END------------------------ shell.layout(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
public static void main(String[] args) throws IOException { List<Emoticon> emoticons = new ArrayList<Emoticon>(); new EmoFormat(emoticons, protocols).load(); Display display = new Display(); shell = new Shell(display); DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE); dialog.setText("Select folder with emoticon images"); String path = dialog.open(); if (path == null) return; // String path = "C:\\Desenvolvimento\\Miranda\\bin\\Debug // Unicode\\Customize\\Emoticons\\Originals"; File mepPath = new File(path); if (!mepPath.exists()) return; mepFormat = new MepFormat(mepPath, emoticons, protocols); mep = mepFormat.load(); createMainWindow(shell); shell.setText("Emoticon Pack Editor"); shell.setImage(Images.get("data/Defaults/smile.png")); shell.setSize(500, 600); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }