Public Methods | |
void | actionPerformed (java.awt.event.ActionEvent ev) |
void | addButton (JButton button, String action) |
void | addButton (AbstractButton button, String action) |
void | addComboBox (JComboBox box, String action) |
JButton | makeButton (String text, String action) |
Protected Methods | |
abstract void | invoke (Method method, Object[] args) throws Exception |
The subclass has to invoke the Method. More... |
Extend this class to add the methods associated to each button action.
|
00024 { 00025 String methodName = ev.getActionCommand(); 00026 00027 try { 00028 Method method = getClass().getMethod(methodName, new Class[0]); 00029 invoke(method, new Object[0]); 00030 } 00031 catch (InvocationTargetException ex) { 00032 ex.getTargetException().printStackTrace(); 00033 } 00034 catch (Exception ex) { 00035 ex.printStackTrace(); 00036 } 00037 } |
|
00040 { 00041 addButton((AbstractButton)button, action); 00042 } |
|
00045 { 00046 checkAction(action); 00047 button.setActionCommand(action); 00048 button.addActionListener(this); 00049 } |
|
00052 { 00053 checkAction(action); 00054 box.setActionCommand(action); 00055 box.addActionListener(this); 00056 } |
|
00059 { 00060 JButton b = new JButton(text); 00061 addButton(b, action); 00062 return b; 00063 } |
|
The subclass has to invoke the Method. ButtonActions can not invoke the method if the subclass is a private inner class. The subclass just have to call method.invoke(this, args). |