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
| public class StartWindow extends Window implements ActionListener {
public StartWindow() {
super(Toolkit.getScreenWidth(), Toolkit.getScreenHeight(), true, "MyFirstApplication");
setShadow(false);
/*- Text label -*/
Label label = new Label("This application enables you to export or to validate exports\nbetween the three environments.");
/*- Buttons -*/
Button export = new Button("Export");
Button validate = new Button("Validate");
/*- Listeners -*/
export.addListener(this);
validate.addListener(this);
/*- Panels -*/
Panel rootPanel = getRootPanel();
BorderPanel buttonPanel = new BorderPanel(Toolkit.getScreenWidth(), 5);
/*- Styles -*/
I5Styles.styleObjects(new Object[] {this, buttonPanel, label, export, validate});
/*- Layout managers -*/
BorderLayoutManager rootLayoutManager = new BorderLayoutManager();
BorderLayoutManager buttonLayoutManager = new BorderLayoutManager();
rootPanel.setLayoutManager(rootLayoutManager);
buttonPanel.setLayoutManager(buttonLayoutManager);
/*- Packing -*/
rootLayoutManager.addWidget(label, BorderLayoutManager.CENTER, WidgetsConstants.ALIGNMENT_CENTER, WidgetsConstants.ALIGNMENT_CENTER);
buttonLayoutManager.addWidget(export, BorderLayoutManager.WEST, WidgetsConstants.ALIGNMENT_CENTER, WidgetsConstants.ALIGNMENT_CENTER);
buttonLayoutManager.addWidget(validate, BorderLayoutManager.EAST, WidgetsConstants.ALIGNMENT_CENTER, WidgetsConstants.ALIGNMENT_CENTER);
rootLayoutManager.addWidget(buttonPanel, BorderLayoutManager.SOUTH, WidgetsConstants.ALIGNMENT_BOTTOM, WidgetsConstants.ALIGNMENT_CENTER);
}
public void actionPerformed(ActionEvent event) {
if (event.getSource() instanceof Button) {
Button button = (Button) event.getSource();
if (button.getLabel().startsWith("Validate")) {
System.out.println("Validate");
} else {
System.out.println("Export");
}
}
}
} |
Partager