View RSS Feed

Java Swing

Swing Action architecture

Rate this Entry
by , 01-08-2012 at 12:28 PM (1372 Views)
Shared behavior between different user interfaces components are implemented by “Swing Action Architecture”. Like tool bar buttons and menu items perform same actions. All the components are disabled when an action is disabled.

Java Code: Swing Action Architecture
class FileAction extends AbstractAction {
//Constructor
FileAction(String name) {
super(name);
}
public void actionPerformed(ActionEvent ae){
//add action logic here
}
}
JMenu fileMenu = new JMenu(“File”);
FileAction newAction = new FileAction(“New”);
JMenuItem item = fileMenu.add(newAction);
item.setAccelaror(KeyStroke.getKeyStroke(‘N’, Event.CTRL_MASK));

Submit "Swing Action architecture" to Facebook Submit "Swing Action architecture" to Digg Submit "Swing Action architecture" to del.icio.us Submit "Swing Action architecture" to StumbleUpon Submit "Swing Action architecture" to Google

Updated 01-14-2012 at 06:56 PM by Java Swing

Categories
Architecture , Actions

Comments