use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class MyStackLayout method open.
void open() {
final Display display = Display.getDefault();
final Shell shell = new Shell();
final Composite comp1 = new Composite(shell, SWT.NONE);
final StackLayout stackLayout = new StackLayout();
final Text txt1 = new Text(comp1, SWT.BORDER);
txt1.setText("T1");
final Text txt2 = new Text(comp1, SWT.BORDER);
txt2.setText("T2");
Composite comp2 = new Composite(shell, SWT.NONE);
comp2.setLayout(new RowLayout());
Button btn1 = new Button(comp2, SWT.NONE);
Button btn2 = new Button(comp2, SWT.NONE);
btn1.setText("T1");
btn2.setText("T2");
comp1.setLayout(stackLayout);
stackLayout.topControl = txt1;
btn1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
stackLayout.topControl = txt1;
comp1.layout();
}
});
btn2.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
stackLayout.topControl = txt2;
comp1.layout();
}
});
shell.setLayout(new FillLayout());
shell.setText("StackLayout");
shell.setSize(200, 200);
// shell.setMaximized(true);
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 ImageCanvasTest method main.
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
ImageViewer ic = new ImageViewer(shell);
shell.setLayout(new FillLayout());
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
dialog.setText("Open an image file or cancel");
String string = dialog.open();
ImageLoader loader = new ImageLoader();
ImageData[] imageDatas = loader.load(string);
if (imageDatas.length == 0)
return;
else if (imageDatas.length == 1) {
ic.setImage(imageDatas[0]);
} else {
ic.setImages(imageDatas, loader.repeatCount);
}
ic.pack();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class ScrolledComposite_TEST method main.
public static void main(String[] args) {
Display display = new Display();
Color red = display.getSystemColor(SWT.COLOR_RED);
Color blue = display.getSystemColor(SWT.COLOR_BLUE);
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
// set the size of the scrolled content - method 1
final ScrolledComposite sc1 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite c1 = new Composite(sc1, SWT.NONE);
sc1.setContent(c1);
c1.setBackground(red);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
c1.setLayout(layout);
Button b1 = new Button(c1, SWT.PUSH);
b1.setText("first button");
c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
// set the minimum width and height of the scrolled content - method 2
final ScrolledComposite sc2 = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
sc2.setExpandHorizontal(true);
sc2.setExpandVertical(true);
final Composite c2 = new Composite(sc2, SWT.NONE);
sc2.setContent(c2);
c2.setBackground(blue);
layout = new GridLayout();
layout.numColumns = 4;
c2.setLayout(layout);
Button b2 = new Button(c2, SWT.PUSH);
b2.setText("first button");
sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Button add = new Button(shell, SWT.PUSH);
add.setText("add children");
final int[] index = new int[] { 0 };
add.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event e) {
index[0]++;
Button button = new Button(c1, SWT.PUSH);
button.setText("button " + index[0]);
// reset size of content so children can be seen - method 1
c1.setSize(c1.computeSize(SWT.DEFAULT, SWT.DEFAULT));
c1.layout();
button = new Button(c2, SWT.PUSH);
button.setText("button " + index[0]);
// reset the minimum width and height so children can be seen - method 2
sc2.setMinSize(c2.computeSize(SWT.DEFAULT, SWT.DEFAULT));
c2.layout();
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class DispelTreeEditorBug method open.
/**
* Open the window
*/
public void open() {
final Display display = Display.getDefault();
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
use of org.eclipse.swt.widgets.Display in project yyl_example by Relucent.
the class BrowserTest method main.
public static void main(String[] args) {
Display display = Display.getDefault();
Shell shell = new Shell();
shell.setLayout(new FillLayout());
Composite compCen = new Composite(shell, SWT.NONE);
compCen.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
compCen.setLayout(new FillLayout());
{
Browser browser = new Browser(compCen, SWT.NONE);
// 显示浏览器首页
browser.setUrl("http://www.baidu.com/");
//ScrolledComposite scrolledComposite = new ScrolledComposite(compCen, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
//scrolledComposite.setExpandHorizontal(true);
//scrolledComposite.setExpandVertical(true);
//scrolledComposite.setContent(widGraphPanel);
}
shell.layout();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
Aggregations