List of usage examples for org.eclipse.swt.widgets Composite setLayout
public void setLayout(Layout layout)
From source file:Draw2DSample.java
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new FillLayout()); Canvas canvas = new Canvas(composite, SWT.NULL); LightweightSystem lws = new LightweightSystem(canvas); Button button = new Button("Button", new Image(getShell().getDisplay(), "java2s.gif")); lws.setContents(button);//from ww w . j a v a 2s .co m return composite; }
From source file:SashExampleTwo.java
/** * Creates the contents of the main window * //from w ww . j av a 2 s. com * @param composite the parent composite */ public void createContents(Composite composite) { composite.setLayout(new FormLayout()); // Create the sash first, so the other controls // can be attached to it. Sash sash = new Sash(composite, SWT.VERTICAL); FormData data = new FormData(); data.top = new FormAttachment(0, 0); // Attach to top data.bottom = new FormAttachment(100, 0); // Attach to bottom data.left = new FormAttachment(50, 0); // Attach halfway across sash.setLayoutData(data); // Create the first text box and attach its right edge // to the sash Text one = new Text(composite, SWT.BORDER); data = new FormData(); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(0, 0); data.right = new FormAttachment(sash, 0); one.setLayoutData(data); // Create the second text box and attach its left edge // to the sash Text two = new Text(composite, SWT.BORDER); data = new FormData(); data.top = new FormAttachment(0, 0); data.bottom = new FormAttachment(100, 0); data.left = new FormAttachment(sash, 0); data.right = new FormAttachment(100, 0); two.setLayoutData(data); }
From source file:ImageRegistryTest.java
/** * Creates the window's contents//from w w w. j a v a 2 s .com * * @param parent the parent composite * @return Control */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new FillLayout()); // Put the images in the registry ImageRegistry ir = new ImageRegistry(); ir.put(ONE, ImageDescriptor.createFromFile(ImageRegistryTest.class, "java2s.gif")); ir.put(TWO, ImageDescriptor.createFromFile(ImageRegistryTest.class, "java2s.gif")); ir.put(THREE, ImageDescriptor.createFromFile(ImageRegistryTest.class, "java2s.gif")); // Create the labels and add the images Label label = new Label(composite, SWT.NONE); label.setImage(ir.get(ONE)); label = new Label(composite, SWT.NONE); label.setImage(ir.get(TWO)); label = new Label(composite, SWT.NONE); label.setImage(ir.get(THREE)); getShell().pack(); return composite; }
From source file:TreeViewerFileFromTree.java
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new FillLayout()); Tree tree = new Tree(composite, SWT.SINGLE); for (int i = 0; i < 4; i++) { TreeItem iItem = new TreeItem(tree, 0); iItem.setText("TreeItem (0) -" + i); for (int j = 0; j < 4; j++) { TreeItem jItem = new TreeItem(iItem, 0); jItem.setText("TreeItem (1) -" + j); for (int k = 0; k < 4; k++) { TreeItem kItem = new TreeItem(jItem, 0); kItem.setText("TreeItem (2) -" + k); for (int l = 0; l < 4; l++) { TreeItem lItem = new TreeItem(kItem, 0); lItem.setText("TreeItem (3) -" + l); for (int m = 0; m < 4; m++) { TreeItem mItem = new TreeItem(lItem, 0); mItem.setText("TreeItem (3) -" + l); }//from ww w . ja v a 2 s .c om } } } } TreeViewer treeViewer = new TreeViewer(tree); return composite; }
From source file:SimpleForm.java
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NULL); composite.setLayout(new GridLayout()); // Sets up the toolkit. FormToolkit toolkit = new FormToolkit(getShell().getDisplay()); // create a form instance. Form form = toolkit.createForm(composite); form.setLayoutData(new GridData(GridData.FILL_BOTH)); form.setText("Eclipse Forms"); form.getBody().setLayout(new GridLayout()); Button button = toolkit.createButton(form.getBody(), "Test", SWT.NULL); // tool bar//from w w w . j a v a 2 s.c om form.getToolBarManager().add(new Action("TEST") { public void run() { } }); Menu menu = new Menu(form.getBody()); MenuItem item = new MenuItem(menu, SWT.NULL); item.setText("Testing item"); form.setMenu(menu); form.updateToolBar(); return composite; }
From source file:ShowError.java
/** * Creates the main window's contents/* w w w . j a v a 2s. co m*/ * * @param parent the main window * @return Control */ protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); // Create a big text box to accept error text final Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); text.setLayoutData(new GridData(GridData.FILL_BOTH)); // Create the button to launch the error dialog Button show = new Button(composite, SWT.PUSH); show.setText("Show Error"); show.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Create the required Status object Status status = new Status(IStatus.ERROR, "My Plug-in ID", 0, "Status Error Message", null); // Display the dialog ErrorDialog.openError(Display.getCurrent().getActiveShell(), "JFace Error", text.getText(), status); } }); return composite; }
From source file:MainClass.java
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, false)); new Label(composite, SWT.LEFT).setText("Please enter your complaints"); Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); text.setLayoutData(new GridData(GridData.FILL_BOTH)); setControl(composite);/*from w ww . ja v a 2s .c o m*/ }
From source file:MainClass.java
public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, true)); new Label(composite, SWT.LEFT).setText("Do you have complaints?"); Composite yesNo = new Composite(composite, SWT.NONE); yesNo.setLayout(new FillLayout(SWT.VERTICAL)); yes = new Button(yesNo, SWT.RADIO); yes.setText("Yes"); no = new Button(yesNo, SWT.RADIO); no.setText("No"); setControl(composite);/*from ww w .j a v a 2 s. c om*/ }
From source file:MainClass.java
protected Control createContents(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(1, true)); final Button indeterminate = new Button(composite, SWT.CHECK); indeterminate.setText("Indeterminate"); Button showProgress = new Button(composite, SWT.NONE); showProgress.setText("Show Progress"); final Shell shell = parent.getShell(); showProgress.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { try { new ProgressMonitorDialog(shell).run(true, true, new LongRunningOperation(indeterminate.getSelection())); } catch (InvocationTargetException e) { MessageDialog.openError(shell, "Error", e.getMessage()); } catch (InterruptedException e) { MessageDialog.openInformation(shell, "Cancelled", e.getMessage()); }// w w w. j a v a 2s .c o m } }); parent.pack(); return composite; }
From source file:RadioButtons.java
public RadioButtons() { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new RowLayout()); Label label = new Label(shell, SWT.NULL); label.setText("Gender: "); label.setBackground(display.getSystemColor(SWT.COLOR_YELLOW)); Button femaleButton = new Button(shell, SWT.RADIO); femaleButton.setText("F"); Button maleButton = new Button(shell, SWT.RADIO); maleButton.setText("M"); label = new Label(shell, SWT.NULL); label.setText(" Title: "); label.setBackground(display.getSystemColor(SWT.COLOR_YELLOW)); Composite composite = new Composite(shell, SWT.NULL); composite.setLayout(new RowLayout()); Button mrButton = new Button(composite, SWT.RADIO); mrButton.setText("Mr."); Button mrsButton = new Button(composite, SWT.RADIO); mrsButton.setText("Mrs."); Button msButton = new Button(composite, SWT.RADIO); msButton.setText("Ms."); Button drButton = new Button(composite, SWT.RADIO); drButton.setText("Dr."); shell.pack();/*from w w w. j av a 2 s. com*/ shell.open(); //textUser.forceFocus(); // Set up the event loop. while (!shell.isDisposed()) { if (!display.readAndDispatch()) { // If no more entries in event queue display.sleep(); } } display.dispose(); }