1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class Snippet {
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
composite.setLayout(new GridLayout(4, false));
Label label = new Label(composite, SWT.None);
label.setText("Texte: ");
GridData labelData = new GridData();
labelData.verticalIndent = 50;
label.setLayoutData(labelData);
Text text = new Text(composite, SWT.BORDER);
GridData textData = new GridData();
textData.verticalIndent = 50;
text.setLayoutData(textData);
Button button = new Button(composite, SWT.PUSH);
GridData buttonData = new GridData();
buttonData.verticalIndent = 50;
buttonData.verticalSpan = 2;
button.setText("Bouton");
button.setLayoutData(buttonData);
Composite keyboardComposite = new Composite(composite, SWT.NONE);
keyboardComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 2));
keyboardComposite.setBackground(display.getSystemColor(SWT.COLOR_BLUE));
keyboardComposite.setLayout(new GridLayout());
Button otherButton = new Button(keyboardComposite, SWT.PUSH);
otherButton.setText("Bouton centré");
otherButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true));
shell.pack();
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
} |
Partager