Disappearing Buttons [message #635328] |
Tue, 26 October 2010 08:52  |
Eclipse User |
|
|
|
I've recently been trying to reorganize a GUI to add in a dropdown menu. The relevant bit of code is as follows:
VerificationModel model;
Text console;
Display display;
Graph graph;
display = new Display();
final Shell shell = new Shell(display);
RowLayout lineLayout = new RowLayout();
lineLayout.wrap = true;
lineLayout.pack = true;
lineLayout.justify = false;
lineLayout.type = SWT.HORIZONTAL;
lineLayout.marginLeft = 5;
lineLayout.marginTop = 5;
lineLayout.marginRight = 5;
lineLayout.marginBottom = 5;
lineLayout.spacing = 10;
RowLayout columnLayout = new RowLayout();
columnLayout.wrap = true;
columnLayout.pack = false;
columnLayout.justify = false;
columnLayout.type = SWT.VERTICAL;
columnLayout.marginLeft = 5;
columnLayout.marginTop = 5;
columnLayout.marginRight = 5;
columnLayout.marginBottom = 5;
columnLayout.spacing = 5;
final int graphWidth = 600;
final int graphHeight = 800;
final int buttonWidth = 200;
final int buttonHeight = 100;
final int consoleWidth = 400;
final int consoleHeight = 400;
/****************************************/
shell.setLayout(lineLayout);
final Composite composite = new Composite(shell, SWT.NONE); //composite forms the left half of the GUI display
composite.setLayout(columnLayout);
final Composite selectables = new Composite(composite, SWT.NONE);
selectables.setLayout(lineLayout);
final Group buttons = new Group(selectables, SWT.NONE);
buttons.setText("Deadlock Search Methods");
buttons.setLayoutData(new RowData((100 + buttonWidth), (100 + buttonHeight*2)));
buttons.setLayout(columnLayout);
/****************************************/
Button button1 = new Button(buttons, SWT.PUSH);
Button button2 = new Button(buttons, SWT.PUSH);
button1.setLayoutData(new RowData(buttonWidth, buttonHeight));
button2.setLayoutData(new RowData(buttonWidth, buttonHeight));
console = new Text(composite, SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
console.setLayoutData(new RowData(consoleWidth, consoleHeight));
Group diagram = new Group(shell, SWT.PUSH);
diagram.setText("BIP model view");
diagram.setLayoutData(new RowData(graphWidth, graphHeight));
diagram.setLayout(lineLayout);
graph = new Graph(diagram, SWT.NONE);
graph.setLayoutData(new RowData(graphWidth-10, graphHeight-10));
graph.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
graph.applyLayout();
shell.pack(); //reduce size to minimum required for all widgets
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
For some reason, the buttons don't appear. I don't encounter that problem when I replace the relevant code with this:
shell.setLayout(lineLayout);
final Composite composite = new Composite(shell, SWT.NONE); //composite forms the left half of the GUI display
composite.setLayout(columnLayout);
//final Composite selectables = new Composite(composite, SWT.NONE);
//selectables.setLayout(lineLayout);
final Group buttons = new Group(composite, SWT.NONE);
//final Group buttons = new Group(selectables, SWT.NONE);
buttons.setText("Deadlock Search Methods");
buttons.setLayoutData(new RowData((100 + buttonWidth), (100 + buttonHeight*2)));
buttons.setLayout(columnLayout);
[Updated on: Tue, 26 October 2010 08:54] by Moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04774 seconds