[Schmitzm-commits] r1760 - trunk/schmitzm-core/src/main/java/de/schmitzm/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Oct 19 15:56:36 CEST 2011


Author: mojays
Date: 2011-10-19 15:56:36 +0200 (Wed, 19 Oct 2011)
New Revision: 1760

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ApplicationFrame.java
Log:


Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ApplicationFrame.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ApplicationFrame.java	2011-10-19 13:32:56 UTC (rev 1759)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ApplicationFrame.java	2011-10-19 13:56:36 UTC (rev 1760)
@@ -5,6 +5,7 @@
 import java.awt.Container;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
 
 import javax.swing.Action;
 import javax.swing.BorderFactory;
@@ -52,7 +53,7 @@
    * @param title frame title
    */
   public ApplicationFrame(String title) {
-    this(title,true);
+    this(title,true,true);
   }
   
   /**
@@ -60,7 +61,7 @@
    * @param title frame title
    * @param pack indicates whether {@link #pack()} is called
    */
-  protected ApplicationFrame(String title, boolean pack) {
+  protected ApplicationFrame(String title, boolean pack, boolean initActions) {
     super(title);
     contentPane = getContentPane();
     contentPane.setLayout(new BorderLayout());
@@ -85,14 +86,26 @@
         }
     };
 
-    initActions();
-    updateActions();
+    if ( initActions ) {
+      initActions();
+      updateActions();
+    }
     
     if( pack )
       pack();
   }
   
   /**
+   * Checks for window closing to call {@link #dispose()} instead of simply terminate the application.
+   */
+  protected void processWindowEvent(WindowEvent e) {
+      super.processWindowEvent(e);
+      if (e.getID() == WindowEvent.WINDOW_CLOSING) {
+          dispose();
+      }
+  }
+
+  /**
    * Creates an {@link Action} which uses the global {@link #menuActionListener}.
    * @param title action title
    * @param commandID command id
@@ -118,6 +131,14 @@
   }
 
   /**
+   * Sets a message to the status bar.
+   * @param statusMess a message
+   */
+  public void setStatusMess(String statusMess) {
+      this.statusBar.setText(statusMess);
+  }
+
+  /**
    * Initializes the actions, menu entries and tool bars.
    */
   protected abstract void initActions();



More information about the Schmitzm-commits mailing list