AbstractAction
, and as such can be simply used in Swing GUIs.protected class PrintAction extends AbstractMDIAction { public PrintAction(String name) { super(app, name); this.setDescription("Print text", "Print text"); } public void run() throws Exception { System.out.println("Hello World"); } }We can execute this action in a background thread in the Menu factory simply by:
PrintAction action = new PrintAction(); getApplication().executeAction(action);
protected class CreateTabAction extends AbstractMDIAction { Object result = null; // will be the result of the action public CreateTabAction(String name) { super(app, name); this.setDescription("Create Tab", "Do something lenghty"); } public void run() throws Exception { result = ... Perform a lengthy computation } public void endAction() { JComponent comp = // create JComponent from result; ((TabbedApplication)app).addTab(pane, result, getActionName()); } }
run()
method:protected class CreateTabAction extends AbstractMDIAction { public CreateTabAction(String name) { super(app, name); this.setDescription("Create Tab", "Do something in the GUI"); } public void run() throws Exception { // do nothing } public void endAction() { JComponent comp = // create the JComponent ((TabbedApplication)app).addTab(pane, result, getActionName()); } }
Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences