[Schmitzm-commits] r661 - branches/2.0-RC2/src/skrueger/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 3 17:50:41 CET 2010


Author: alfonx
Date: 2010-02-03 17:50:39 +0100 (Wed, 03 Feb 2010)
New Revision: 661

Modified:
   branches/2.0-RC2/src/skrueger/swing/CancellableDialogAdapter.java
Log:
* Added a default Ok/CancelButton to CancellableDialogAdapter


Modified: branches/2.0-RC2/src/skrueger/swing/CancellableDialogAdapter.java
===================================================================
--- branches/2.0-RC2/src/skrueger/swing/CancellableDialogAdapter.java	2010-02-03 16:10:12 UTC (rev 660)
+++ branches/2.0-RC2/src/skrueger/swing/CancellableDialogAdapter.java	2010-02-03 16:50:39 UTC (rev 661)
@@ -2,8 +2,10 @@
 
 import java.awt.Component;
 import java.awt.Dialog;
+import java.awt.event.ActionEvent;
 import java.util.Locale;
 
+import javax.swing.AbstractAction;
 import javax.swing.JDialog;
 import javax.swing.JOptionPane;
 
@@ -29,6 +31,9 @@
 
 	/** Has this dialog been canceled ?**/
 	protected boolean cancelled = false;
+
+	private OkButton okButton;
+	private CancelButton cancelButton;
 	
 	public CancellableDialogAdapter(Component parentWindow) {
 		super(parentWindow);
@@ -107,7 +112,38 @@
 		dispose();
 		return true;
 	}
+
+	/**
+	 * @return a default OkButton that will call {@link #okClose()}
+	 */
+	protected OkButton getOkButton() {
+		if (okButton == null) {
+			okButton = new OkButton(new AbstractAction() {
+				
+				@Override
+				public void actionPerformed(ActionEvent e) {
+					okClose();
+				}
+			});
+		}
+		return okButton;
+	}
 	
 
+	/**
+	 * @return a default CancelButton that will call {@link #cancelClose()}
+	 */
+	protected CancelButton getCancelButton() {
+		if (cancelButton == null) {
+			cancelButton = new CancelButton(new AbstractAction() {
+				
+				@Override
+				public void actionPerformed(ActionEvent e) {
+					cancelClose();
+				}
+			});
+		}
+		return cancelButton;
+	}
 
 }



More information about the Schmitzm-commits mailing list