Java by API/org.eclipse.swt.layout/FillLayout
Версия от 17:43, 31 мая 2010; (обсуждение)
new FillLayout()
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell s = new Shell(d);
s.setSize(250, 200);
s.setText("A Table Shell Example");
s.setLayout(new FillLayout());
Tree t = new Tree(s, SWT.SINGLE | SWT.BORDER);
TreeItem child1 = new TreeItem(t, SWT.NONE, 0);
child1.setText("1");
TreeItem child2 = new TreeItem(t, SWT.NONE, 1);
child2.setText("2");
TreeItem child2a = new TreeItem(child2, SWT.NONE, 0);
child2a.setText("2A");
TreeItem child2b = new TreeItem(child2, SWT.NONE, 1);
child2b.setText("2B");
TreeItem child3 = new TreeItem(t, SWT.NONE, 2);
child3.setText("3");
s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}
new FillLayout(int i)
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class MainClass {
public static void main(String[] a) {
final Display d = new Display();
final Shell s = new Shell(d);
s.setSize(300, 300);
s.setText("A ColorDialog Example");
s.setLayout(new FillLayout(SWT.VERTICAL));
final Text t = new Text(s, SWT.BORDER | SWT.MULTI);
final Button b = new Button(s, SWT.PUSH | SWT.BORDER);
b.setText("Change Color");
b.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ColorDialog cd = new ColorDialog(s);
cd.setText("ColorDialog Demo");
cd.setRGB(new RGB(255, 255, 255));
RGB newColor = cd.open();
if (newColor == null) {
return;
}
t.setBackground(new Color(d, newColor));
}
});
s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch())
d.sleep();
}
d.dispose();
}
}