I really think the swt-designer is great.
Here's one suggestion to improve the "control in Block" issue that will also help to later access the control's values:
Can the designer code add the declaration for the new control at the beginning of the class and only instantiate them in the blocks?
Here's a sample of the output I'd like to see:
- Code: Select all
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
/**
* @author Christian (with SWT-Designer base)
*
*/
public class RTFNext {
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell();
final Label label; //<--- put the declaration here
final Text text; //<--- put the declaration here
final Button button; //<--- put the declaration here
shell.setLayout(new FillLayout(SWT.VERTICAL));
shell.setText("SWT Application");
shell.setBounds(50,100,50,100);
{
label = new Label(shell, SWT.NONE);
label.setText("Your Input:");
}
{
text = new Text(shell, SWT.BORDER);
text.setText("");
}
{
button = new Button(shell, SWT.NONE);
button.addMouseListener(new MouseAdapter() {
public void mouseUp(MouseEvent e) {
MessageBox msg = new MessageBox(shell);
msg.setText("What you typed:");
msg.setMessage(text.getText());
msg.open();
}
});
button.setToolTipText("Click Now!");
button.setText("OK (Click Me)");
}
// DESIGNER: Add controls before this line.
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
}
Thanks,
Christian