I am trying to create a base dialog class using SWT and JFace:
public class AplotBaseDialog extends TitleAreaDialog
I am confused about how to layout the dialog?
Doing it in Swing I would have a createDialog method. Then in that method I would add Components that was JPanel methods. Then add the components to my centerPanel. Which was the base dialog. Each Panel method had their own layout.
This is a very simple example (Pseudo Code)
public void createDialog() {
Component selectionsPanel = createTableArea();
Component buttonPanel = OKCancelButtons();
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.PAGE_AXIS));
centerPanel.add(selectionsPanel);
centerPanel.add(buttonPanel);
getContentPane().add(centerPanel);
this.pack();
centerPanel.setVisible(true);
}
private JPanel OKCancelButtons() {
submitButton = new JButton("Send");
etc... etc..
JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.LINE_AXIS));
p.add(submitButton);
return p;
}
private JPanel createTableArea() {
JPanel p = new JPanel();
similar to above but a Table;
return p;
}
You can see how I was creating the Panels in the methods than adding them to the base panel as components.
How would you do that using TitleAreaDialog?
I haven’t used
TitleAreaDialogyet, but here is a simpleDialogI use myself. It should give you an idea about the inner workings of a dialog. It’s basically just a dialog with some error message and a checkbox:As you can see, there is no
addmethod in SWT. You just specify the parent in the constructor of each widget.Moreover, here is a really good tutorial by Vogella, that explains in detail how to create a JFace dialog. Here is another example on how to use the
TitleAreaDialog.