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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sun Feb 13 16:00:44 CET 2011


Author: alfonx
Date: 2011-02-13 16:00:43 +0100 (Sun, 13 Feb 2011)
New Revision: 1501

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AtlasDialog.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/CancellableTabbedDialogAdapter.java
Log:
MigLayout hack for better packing fo GUIs

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AtlasDialog.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AtlasDialog.java	2011-02-12 19:39:04 UTC (rev 1500)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/AtlasDialog.java	2011-02-13 15:00:43 UTC (rev 1501)
@@ -12,6 +12,7 @@
 import javax.swing.JDialog;
 import javax.swing.JRootPane;
 import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
 
 import net.miginfocom.swing.MigLayout;
 
@@ -124,4 +125,22 @@
 		}
 		return cancelButton;
 	}
+
+	@Override
+	/**
+	 * http://migcalendar.com/forum/viewtopic.php?f=8&t=2261
+	 * MigLayout hs troubles when Swing wraps HTML JLabels.. This is a bugfix
+	 */
+	public void pack() {
+		super.pack();
+
+		SwingUtilities.invokeLater(new Runnable() {
+
+			@Override
+			public void run() {
+				AtlasDialog.super.pack();
+			}
+		});
+
+	}
 }

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/CancellableTabbedDialogAdapter.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/CancellableTabbedDialogAdapter.java	2011-02-12 19:39:04 UTC (rev 1500)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/CancellableTabbedDialogAdapter.java	2011-02-13 15:00:43 UTC (rev 1501)
@@ -34,16 +34,16 @@
 				// CancellableTabbedDialogAdapter.this.getContentPane()
 				// .getPreferredSize().height
 				// + buttons.getPreferredSize().height);
-				CancellableTabbedDialogAdapter.this.pack();
+				// CancellableTabbedDialogAdapter.this.pack();
+				//
+				// SwingUtil.setHeight(CancellableTabbedDialogAdapter.this
+				// .getContentPane(), CancellableTabbedDialogAdapter.this
+				// .getContentPane().getHeight() + 32);
+				// SwingUtil.setPreferredHeight(
+				// CancellableTabbedDialogAdapter.this.getContentPane(),
+				// CancellableTabbedDialogAdapter.this.getContentPane()
+				// .getHeight() + 32);
 
-				SwingUtil.setHeight(CancellableTabbedDialogAdapter.this
-						.getContentPane(), CancellableTabbedDialogAdapter.this
-						.getContentPane().getHeight() + 22);
-				SwingUtil.setPreferredHeight(
-						CancellableTabbedDialogAdapter.this.getContentPane(),
-						CancellableTabbedDialogAdapter.this.getContentPane()
-								.getHeight() + 22);
-
 			}
 		};
 
@@ -56,9 +56,9 @@
 		 * Building the content pane
 		 */
 		final JPanel contentPane = new JPanel(new MigLayout(
-				"wrap 1, gap 0, inset 0"));
-		contentPane.add(getTabbedPane());
-		contentPane.add(buttons);
+				"wrap 1, gap 0, inset 0", "[100%]", "grow, push"));
+		contentPane.add(getTabbedPane(), "grow, push");
+		contentPane.add(buttons, "bottom, grow, push");
 
 		setContentPane(contentPane);
 



More information about the Schmitzm-commits mailing list