I am trying to take the following method of Swing code and migrate to SWT for my application.
I know some of it.
SWT SWING
Label JLabel
Button JButton
Dialog JDailog
??? Box
The method looks like it is creating a status dialog and has a cancel button.
How could I do the same but in SWT?
I am not sure what Swing Box is doing?
Is this basically a simple dialog with a cancel button and some labels?
private void createPrintDialog() {
pd = new JDialog((Frame) null, "Printing...", false);
Container top = pd.getContentPane();
Box lines = Box.createVerticalBox();
Box line = Box.createHorizontalBox();
line.add(new Label("Now printing: "));
Label title = new Label("file.pdf");
line.add(title);
lines.add(line);
line = Box.createHorizontalBox();
line.add(Box.createHorizontalStrut(10));
line.add(new Label("page "));
pagenumlabel = new JLabel("1");
line.add(pagenumlabel);
line.add(new JLabel(" of "));
JLabel totalpages = new JLabel(String.valueOf(file.getNumPages()));
line.add(totalpages);
lines.add(line);
top.add(lines, BorderLayout.CENTER);
Box cancelbox = Box.createHorizontalBox();
cancelbox.add(Box.createHorizontalGlue());
cancel = new JButton(new AbstractAction("Cancel") {
public void actionPerformed(ActionEvent evt) {
doCancel();
}
});
cancelbox.add(cancel);
top.add(cancelbox, BorderLayout.SOUTH);
}
Use
org.eclipse.jface.dialogs.MessageDialog. ( There are static method open Error,Info…etc. use it as per your needs)