[Schmitzm-commits] r120 - trunk/src/skrueger/swing

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat May 16 23:25:45 CEST 2009


Author: alfonx
Date: 2009-05-16 23:25:44 +0200 (Sat, 16 May 2009)
New Revision: 120

Modified:
   trunk/src/skrueger/swing/TranslationAskJDialog.java
Log:
* Possibility to ass more buttons to the button panel by #setButtons(JButton... )

Modified: trunk/src/skrueger/swing/TranslationAskJDialog.java
===================================================================
--- trunk/src/skrueger/swing/TranslationAskJDialog.java	2009-05-16 14:33:54 UTC (rev 119)
+++ trunk/src/skrueger/swing/TranslationAskJDialog.java	2009-05-16 21:25:44 UTC (rev 120)
@@ -14,6 +14,7 @@
 import javax.swing.AbstractAction;
 import javax.swing.Action;
 import javax.swing.Box;
+import javax.swing.JButton;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.JOptionPane;
@@ -49,6 +50,8 @@
 
 	private boolean hasBeenCanceled;
 
+	private JButton[] optionalButtons;
+
 	/**
 	 * Since the registerKeyboardAction() method is part of the JComponent class
 	 * definition, you must define the Escape keystroke and register the
@@ -164,6 +167,11 @@
 		pack();
 	}
 
+	public void setButtons(JButton... optionalButtons) {
+		this.optionalButtons = optionalButtons;
+		init();
+	}
+
 	protected void cancel() {
 		firePropertyChange(PROPERTY_CANCEL_AND_CLOSE, null, null);
 		restore();
@@ -183,6 +191,12 @@
 
 	private JComponent getButtons() {
 		JPanel jPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+
+		if (optionalButtons != null)
+			for (JButton b : optionalButtons) {
+				jPanel.add(b);
+			}
+
 		if (okButton == null) {
 			okButton = new OkButton(new AbstractAction() {
 				{



More information about the Schmitzm-commits mailing list