use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class CursorTest method main.
public static void main(String[] args) {
try {
final Display display = Display.getDefault();
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setLayout(new FillLayout());
final List list = new List(shell, SWT.BORDER);
final Composite composite = new Composite(shell, SWT.NONE);
CURSOR[] CURSORS = CURSOR.values();
String[] itemnames = new String[CURSORS.length];
for (int i = 0; i < CURSORS.length; i++) {
itemnames[i] = CURSORS[i].name();
}
list.setItems(itemnames);
list.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
composite.setCursor(new Cursor(display, list.getSelectionIndex()));
}
});
shell.setText("SWT Cursor");
shell.setSize(500, 320);
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class HelloCanvasArrow method open.
public void open() {
final Display display = Display.getDefault();
final Shell shell = new Shell();
shell.setLayout(new FillLayout());
final Canvas canvas = new Canvas(shell, SWT.NONE);
canvas.setCursor(SWTResourceManager.getCursor(SWT.CURSOR_ARROW));
canvas.addMouseListener(new MouseListener() {
public void mouseDoubleClick(MouseEvent arg0) {
}
public void mouseDown(MouseEvent e) {
p[0] = e.x;
p[1] = e.y;
b = true;
}
public void mouseUp(MouseEvent arg0) {
if (b) {
int[] tp = new int[4];
tp[0] = p[0];
tp[1] = p[0];
tp[2] = p[0];
tp[3] = p[3];
}
b = false;
}
});
canvas.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent e) {
p[2] = e.x;
p[3] = e.y;
canvas.redraw();
}
});
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent paintevent) {
if (b) {
paintArrow(paintevent.gc, new Point(p[0], p[1]), new Point(p[2], p[3]));
}
}
});
shell.setText("test");
shell.setSize(300, 300);
shell.layout();
shell.open();
while (!shell.isDisposed()) if (!display.readAndDispatch())
display.sleep();
}
use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class MyFillLayout method open.
public void open() {
final Display display = Display.getDefault();
shell = new Shell();
fillLayout = new FillLayout();
//# fillLayout.type=SWT.VERTICAL;
//# fillLayout.type=SWT.HORIZONTAL;
shell.setLayout(fillLayout);
btnHorizontal = new Button(shell, SWT.NONE);
btnHorizontal.setText("HORIZONTAL");
btnHorizontal.addMouseListener(this);
btnVertical = new Button(shell, SWT.NONE);
btnVertical.setText("VERTICAL");
btnVertical.addMouseListener(this);
shell.setText("FillLayout");
shell.setSize(200, 200);
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class MyFormLayout method main.
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
FormLayout formLayout = new FormLayout();
formLayout.marginWidth = 20;
formLayout.marginHeight = 20;
new Button(shell, SWT.NONE).setText("B1");
Button b = new Button(shell, SWT.NONE);
b.setText("B2");
FormData formData = new FormData(100, 100);
b.setLayoutData(formData);
shell.setLayout(formLayout);
shell.setText("FormLayout");
shell.setSize(200, 200);
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class MyRowLayout method main.
public static void main(String[] args) {
final Display display = Display.getDefault();
final Shell shell = new Shell();
RowLayout rowLayout = new RowLayout();
rowLayout.marginTop = 10;
rowLayout.marginLeft = 5;
rowLayout.spacing = 2;
// true or false
rowLayout.wrap = true;
rowLayout.type = SWT.HORIZONTAL;
//# rowLayout.type = SWT.VERTICAL;
rowLayout.pack = true;
rowLayout.justify = false;
new Button(shell, SWT.NONE).setText("b1");
new Button(shell, SWT.NONE).setText("button2");
Button b = new Button(shell, SWT.NONE);
b.setText("btn3");
RowData rowData = new RowData(50, 50);
b.setLayoutData(rowData);
shell.setLayout(rowLayout);
shell.setText("RowLayout");
shell.setSize(200, 200);
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
Aggregations