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
|
private void initGUI() {
try {
this.setLayout(new FormLayout());
this.setSize(406, 209);
{
sashForm1 = new SashForm(this, SWT.NONE);
FormData sashForm1LData = new FormData();
sashForm1LData.width = 406;
sashForm1LData.height = 209;
sashForm1LData.left = new FormAttachment(0, 1000, 0);
sashForm1LData.top = new FormAttachment(0, 1000, 0);
sashForm1LData.right = new FormAttachment(1000, 1000, 0);
sashForm1LData.bottom = new FormAttachment(1000, 1000, 0);
sashForm1.setLayoutData(sashForm1LData);
{
composite1 = new Composite(sashForm1, SWT.NONE);
GridLayout composite1Layout = new GridLayout();
composite1Layout.makeColumnsEqualWidth = true;
composite1.setLayout(composite1Layout);
composite1.setBounds(32, 39, 406, 209);
{
button1 = new Button(composite1, SWT.PUSH | SWT.CENTER);
button1.setText("button1");
}
{
button2 = new Button(composite1, SWT.PUSH | SWT.CENTER);
button2.setText("button2");
}
}
{
canvas1 = new Canvas(sashForm1, SWT.NONE);
canvas1.setBounds(5, 5, 64, 64);
canvas1.setBackground(SWTResourceManager.getColor(255, 128, 0));
}
sashForm1.setWeights(new int[] {4, 6});
}
this.layout();
this.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
int percent = 406*100 / getSize().x;
if (percent <= 100) {
sashForm1.setWeights(new int[] {percent, 100-percent});
}
}});
} catch (Exception e) {
e.printStackTrace();
}
} |
Partager