KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > prevayler > demos > demo2 > gui > RobustAction


1 package org.prevayler.demos.demo2.gui;
2
3 import javax.swing.*;
4 import java.awt.event.ActionEvent JavaDoc;
5
6 abstract class RobustAction extends AbstractAction {
7         
8     RobustAction(String JavaDoc name) {
9         super(name);
10     }
11
12     public void actionPerformed(ActionEvent JavaDoc e) {
13         try {
14             action();
15         } catch (Exception JavaDoc exception) {
16             display(exception);
17         }
18     }
19         
20     protected abstract void action() throws Exception JavaDoc;
21     
22     static void display(Exception JavaDoc exception) {
23         JOptionPane.showMessageDialog(null, exception.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
24     }
25 }
26
Popular Tags