Coverage Report - net.miginfocom.demo.SwingDemo
 
Classes in this File Line Coverage Branch Coverage Complexity
SwingDemo
N/A
N/A
2.988
SwingDemo$1
N/A
N/A
2.988
SwingDemo$10
N/A
N/A
2.988
SwingDemo$11
N/A
N/A
2.988
SwingDemo$12
N/A
N/A
2.988
SwingDemo$2
N/A
N/A
2.988
SwingDemo$3
N/A
N/A
2.988
SwingDemo$4
N/A
N/A
2.988
SwingDemo$5
N/A
N/A
2.988
SwingDemo$5$1
N/A
N/A
2.988
SwingDemo$5$2
N/A
N/A
2.988
SwingDemo$6
N/A
N/A
2.988
SwingDemo$6$1
N/A
N/A
2.988
SwingDemo$6$2
N/A
N/A
2.988
SwingDemo$7
N/A
N/A
2.988
SwingDemo$8
N/A
N/A
2.988
SwingDemo$9
N/A
N/A
2.988
SwingDemo$ConstraintListener
N/A
N/A
2.988
SwingDemo$ConstraintsDialog
N/A
N/A
2.988
SwingDemo$ConstraintsDialog$1
N/A
N/A
2.988
SwingDemo$ConstraintsDialog$1$1
N/A
N/A
2.988
SwingDemo$ToolTipListener
N/A
N/A
2.988
 
 1  
 package net.miginfocom.demo;
 2  
 
 3  
 import net.miginfocom.layout.*;
 4  
 import net.miginfocom.swing.MigLayout;
 5  
 
 6  
 import javax.swing.*;
 7  
 import javax.swing.border.EmptyBorder;
 8  
 import javax.swing.border.EtchedBorder;
 9  
 import javax.swing.border.LineBorder;
 10  
 import javax.swing.event.ListSelectionEvent;
 11  
 import javax.swing.event.ListSelectionListener;
 12  
 import java.awt.*;
 13  
 import java.awt.event.*;
 14  
 import java.io.FileWriter;
 15  
 import java.io.IOException;
 16  
 import java.io.PrintWriter;
 17  
 import java.io.StringWriter;
 18  
 import java.util.Random;
 19  
 
 20  
 /*
 21  
  * License (BSD):
 22  
  * ==============
 23  
  *
 24  
  * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
 25  
  * All rights reserved.
 26  
  *
 27  
  * Redistribution and use in source and binary forms, with or without modification,
 28  
  * are permitted provided that the following conditions are met:
 29  
  * Redistributions of source code must retain the above copyright notice, this list
 30  
  * of conditions and the following disclaimer.
 31  
  * Redistributions in binary form must reproduce the above copyright notice, this
 32  
  * list of conditions and the following disclaimer in the documentation and/or other
 33  
  * materials provided with the distribution.
 34  
  * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
 35  
  * used to endorse or promote products derived from this software without specific
 36  
  * prior written permission.
 37  
  *
 38  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 39  
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 40  
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 41  
  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 42  
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 43  
  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 44  
  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 45  
  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 46  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 47  
  * OF SUCH DAMAGE.
 48  
  *
 49  
  * @version 1.0
 50  
  * @author Mikael Grev, MiG InfoCom AB
 51  
  *         Date: 2006-sep-08
 52  
  */
 53  
 public class SwingDemo extends JFrame
 54  
 {
 55  
         public static final int INITIAL_INDEX = 0;
 56  
         private static final boolean DEBUG = false;
 57  
         private static final boolean OPAQUE = false;
 58  
 
 59  
         private static final String[][] panels = new String[][] {
 60  
 //                {"Test", "BugTestApp, disregard"},
 61  
                 {"Welcome", "\n\n         \"MigLayout makes complex layouts easy and normal layouts one-liners.\""},
 62  
                 {"Quick Start", "This is an example of how to build a common dialog type. Note that there are no special components, nested panels or absolute references to cell positions. If you look at the source code you will see that the layout code is very simple to understand."},
 63  
                 {"Plain", "A simple example on how simple it is to create normal forms. No builders needed since the whole layout manager works like a builder."},
 64  
                 {"Alignments", "Shows how the alignment of components are specified. At the top/left is the alignment for the column/row. The components have no alignments specified.\n\nNote that baseline alignment will be interpreted as 'center' before JDK 6."},
 65  
                 {"Cell Alignments", "Shows how components are aligned when both column/row alignments and component constraints are specified. At the top/left are the alignment for the column/row and the text on the buttons is the component constraint that will override the column/row alignment if it is an alignment.\n\nNote that baseline alignment will be interpreted as 'center' before JDK 6."},
 66  
                 {"Basic Sizes", "A simple example that shows how to use the column or row min/preferred/max size to set the sizes of the contained components and also an example that shows how to do this directly in the component constraints."},
 67  
                 {"Growing", "A simple example that shows how to use the growx and growy constraint to set the sizes and how they should grow to fit the available size. Both the column/row and the component grow/shrink constraints can be set, but the components will always be confined to the space given by its column/row."},
 68  
                 {"Grow Shrink", "Demonstrates the very flexible grow and shrink constraints that can be set on a component.\nComponents can be divided into grow/shrink groups and also have grow/shrink weight within each of those groups.\n\nBy default " +
 69  
                                                 "components shrink to their inherent (or specified) minimum size, but they don't grow."},
 70  
                 {"Span", "This example shows the powerful spanning and splitting that can be specified in the component constraints. With spanning any number of cells can be merged with the additional option to split that space for more than one component. This makes layouts very flexible and reduces the number of times you will need nested panels to very few."},
 71  
                 {"Flow Direction", "Shows the different flow directions. Flow direction for the layout specifies if the next cell will be in the x or y dimension. Note that it can be a different flow direction in the slit cell (the middle cell is slit in two). Wrap is set to 3 for all panels."},
 72  
                 {"Grouping", "Sizes for both components and columns/rows can be grouped so they get the same size. For instance buttons in a button bar can be given a size-group so that they will all get " +
 73  
                                          "the same minimum and preferred size (the largest within the group). Size-groups can be set for the width, height or both."},
 74  
                 {"Units", "Demonstrates the basic units that are understood by MigLayout. These units can be extended by the user by adding one or more UnitConverter(s)."},
 75  
                 {"Component Sizes", "Minimum, preferred and maximum component sizes can be overridden in the component constraints using any unit type. The format to do this is short and simple to understand. You simply specify the " +
 76  
                                                         "min, preferred and max sizes with a colon between.\n\nAbove are some examples of this. An exclamation mark means that the value will be used for all sizes."},
 77  
                 {"Bound Sizes", "Shows how to create columns that are stable between tabs using minimum sizes."},
 78  
                 {"Cell Position", "Even though MigLayout has automatic grid flow you can still specify the cell position explicitly. You can even combine absolute (x, y) and flow (skip, wrap and newline) constraints to build your layout."},
 79  
                 {"Orientation", "MigLayout supports not only right-to-left orientation, but also bottom-to-top. You can even set the flow direction so that the flow is vertical instead of horizontal. It will automatically " +
 80  
                                                 "pick up if right-to-left is to be used depending on the ComponentWrapper, but it can also be manually set for every layout."},
 81  
                 {"Absolute Position", "Demonstrates the option to place any number of components using absolute coordinates. This can be just the position (if min/preferred size) using \"x y p p\" format or" +
 82  
                                                           "the bounds using the \"x1 y1 x2 y2\" format. Any unit can be used and percent is relative to the parent.\nAbsolute components will not disturb the flow or occupy cells in the grid. " +
 83  
                                                           "Absolute positioned components will be taken into account when calculating the container's preferred size."},
 84  
                 {"Component Links", "Components can be linked to any side of any other component. It can be a forward, backward or cyclic link references, as long as it is stable and won't continue to change value over many iterations." +
 85  
                                                         "Links are referencing the ID of another component. The ID can be overridden by the component's constrains or is provided by the ComponentWrapper. For instance it will use the component's 'name' on Swing.\n" +
 86  
                                                         "Since the links can be combined with any expression (such as 'butt1.x+10' or 'max(button.x, 200)' the links are very customizable."},
 87  
                 {"Docking", "Docking components can be added around the grid. The docked component will get the whole width/height on the docked side by default, however this can be overridden. When all docked components are laid out, whatever space " +
 88  
                                         "is left will be available for the normal grid laid out components. Docked components does not in any way affect the flow in the grid.\n\nSince the docking runs in the same code path " +
 89  
                                         "as the normal layout code the same properties can be specified for the docking components. You can for instance set the sizes and alignment or link other components to their docked component's bounds."},
 90  
                 {"Button Bars", "Button order is very customizable and are by default different on the supported platforms. E.g. Gaps, button order and minimum button size are properties that are 'per platform'. MigLayout picks up the current platform automatically and adjusts the button order and minimum button size accordingly, all without using a button builder or any other special code construct."},
 91  
                 {"Visual Bounds", "Human perceptible bounds may not be the same as the mathematical bounds for the component. This is for instance the case if there is a drop shadow painted by the component's border. MigLayout can compensate " +
 92  
                                                   "for this in a simple way. Note the top middle tab-component, it is not aligned visually correct on Windows XP. For the second tab the bounds are corrected automatically on Windows XP."},
 93  
                 {"Debug", "Demonstrates the non-intrusive way to get visual debugging aid. There is no need to use a special DebugPanel or anything that will need code changes. The user can simply turn on debug on the layout manager by using the \"debug\" constraint and it will " +
 94  
                                   "continuously repaint the panel with debug information on top. This means you don't have to change your code to debug!"},
 95  
                 {"Layout Showdown", "This is an implementation of the Layout Showdown posted on java.net by John O'Conner. The first tab is a pure implemenetation of the showdown that follows all the rules. The second tab is a slightly fixed version that follows some improved layout guidelines." +
 96  
                                     "The source code is for both the first and for the fixed version. Note the simplification of the code for the fixed version. Writing better layouts with MiG Layout is reasier that writing bad.\n\nReference: http://weblogs.java.net/blog/joconner/archive/2006/10/more_informatio.html"},
 97  
                 {"API Constraints1", "This dialog shows the constraint API added to v2.0. It works the same way as the string constraints but with chained method calls. See the source code for details."},
 98  
                 {"API Constraints2", "This dialog shows the constraint API added to v2.0. It works the same way as the string constraints but with chained method calls. See the source code for details."}
 99  
         };
 100  
 
 101  
         private int lastIndex = -10;
 102  
 
 103  
         private JPanel contentPanel = DEBUG ? new JPanel(new BorderLayout()) : new JPanel(new MigLayout("wrap", "[]unrel[grow]", "[grow][pref]"));
 104  
 
 105  
         private JTabbedPane layoutPickerTabPane = new JTabbedPane();
 106  
                 private JList pickerList = new JList(new DefaultListModel());
 107  
 
 108  
         private JTabbedPane southTabPane = new JTabbedPane();
 109  
                 private JScrollPane descrTextAreaScroll = createTextAreaScroll("", 5, 80, true);
 110  
                 private JTextArea descrTextArea = (JTextArea) descrTextAreaScroll.getViewport().getView();
 111  
 
 112  
                 private JScrollPane sourceTextAreaScroll = null;
 113  
                 private JTextArea sourceTextArea = null;
 114  
 
 115  
         private JPanel layoutDisplayPanel = new JPanel(new BorderLayout(0, 0));
 116  
         private static boolean buttonOpaque = true;
 117  
         private static boolean contentAreaFilled = true;
 118  
         private JFrame sourceFrame = null;
 119  
         private JTextArea sourceFrameTextArea = null;
 120  
 
 121  
         private static int benchRuns = 0;
 122  
         private static long startupMillis = 0;
 123  
         private static long timeToShowMillis = 0;
 124  
         private static long benchRunTime = 0;
 125  
         private static String benchOutFileName = null;
 126  
         private static boolean append = false;
 127  
         private static long lastRunTimeStart = 0;
 128  
         private static StringBuffer runTimeSB = null;
 129  
 
 130  
         public static void main(String args[])
 131  
         {
 132  
                 try {
 133  
                         System.setProperty("apple.laf.useScreenMenuBar", "true");
 134  
                         System.setProperty("com.apple.mrj.application.apple.menu.about.name", "MiGLayout Swing Demo");
 135  
                 } catch(Throwable ex) {
 136  
                         // Beacuse we did not have permissions.
 137  
                 }
 138  
 
 139  
                 startupMillis = System.currentTimeMillis();
 140  
 
 141  
                 String laf = UIManager.getSystemLookAndFeelClassName();
 142  
 
 143  
                 if (args.length > 0) {
 144  
                         for (int i = 0; i <args.length; i++) {
 145  
                                 String arg = args[i].trim();
 146  
                                 if (arg.startsWith("-laf")) {
 147  
                                         laf = arg.substring(4);
 148  
                                 } else if (arg.startsWith("-bench")) {
 149  
                                         benchRuns = 10;
 150  
                                         try {
 151  
                                                 benchRuns = Integer.parseInt(arg.substring(6));
 152  
                                         } catch(Exception ex) {}
 153  
                                 } else if (arg.startsWith("-bout")) {
 154  
                                         benchOutFileName = arg.substring(5);
 155  
                                 } else if (arg.startsWith("-append")) {
 156  
                                         append = true;
 157  
                                 } else if (arg.startsWith("-verbose")) {
 158  
                                         runTimeSB = new StringBuffer(256);
 159  
                                 } else if (arg.equals("-steel")) {
 160  
                                         laf = "javax.swing.plaf.metal.MetalLookAndFeel";
 161  
                                         System.setProperty("swing.metalTheme", "steel");
 162  
                                 } else if (arg.equals("-ocean")) {
 163  
                                         laf = "javax.swing.plaf.metal.MetalLookAndFeel";
 164  
                                 } else {
 165  
                                         System.out.println("Usage: [-laf[look_&_feel_class_name]] [-bench[#_of_runs]] [-bout[benchmark_results_filename]] [-append] [-steel] [-ocean]\n" +
 166  
                                                            " -laf    Set the Application Look&Feel. (Look and feel must be in Classpath)\n" +
 167  
                                                            " -bench  Run demo as benchmark. Run count can be appended. 10 is default.\n" +
 168  
                                                            " -bout   Benchmark results output filename.\n" +
 169  
                                                            " -append Appends the result to the -bout file.\n" +
 170  
                                                            " -verbose Print the times of every run.\n" +
 171  
                                                            " -steel  Sets the old Steel theme for Sun's Metal look&feel.\n" +
 172  
                                                            " -ocean  Sets the Ocean theme for Sun's Metal look&feel.\n" +
 173  
                                                            "\nExamples:\n" +
 174  
                                                            " java -jar swingdemoapp.jar -bench -boutC:/bench.txt -append\n" +
 175  
                                                            " java -jar swingdemoapp.jar -ocean -bench20\n" +
 176  
                                                            " java -cp c:\\looks-2.0.4.jar;.\\swingdemoapp.jar net.miginfocom.demo.SwingDemo -lafcom.jgoodies.looks.plastic.PlasticLookAndFeel -bench20 -boutC:/bench.txt");
 177  
                                         System.exit(0);
 178  
                                 }
 179  
                         }
 180  
                 }
 181  
 
 182  
                 if (benchRuns == 0)
 183  
                         LayoutUtil.setDesignTime(null, true); // So that the string constraints to create the UnitValues is saved and can be recreated exactly.
 184  
 
 185  
 //                laf = "net.sourceforge.napkinlaf.NapkinLookAndFeel";
 186  
 //                laf = "javax.swing.plaf.metal.MetalLookAndFeel";
 187  
 //                System.setProperty("swing.metalTheme", "steel");
 188  
 //                laf = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
 189  
 //                laf = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
 190  
 //                laf = "com.jgoodies.looks.plastic.PlasticLookAndFeel";
 191  
 //                laf = "com.jgoodies.looks.plastic.Plastic3DLookAndFeel";
 192  
 //                laf = "com.jgoodies.looks.plastic.PlasticXPLookAndFeel";
 193  
 //                laf = "com.jgoodies.looks.windows.WindowsLookAndFeel";
 194  
 
 195  
                 if (laf.endsWith("WindowsLookAndFeel"))
 196  
                         buttonOpaque = false;
 197  
 
 198  
                 if (laf.endsWith("AquaLookAndFeel"))
 199  
                         contentAreaFilled = false;
 200  
 
 201  
                 final String laff = laf;
 202  
 
 203  
                 SwingUtilities.invokeLater(new Runnable() {
 204  
                         public void run() {
 205  
                                 try {
 206  
                                         UIManager.setLookAndFeel(laff);
 207  
                                 } catch (Exception ex) {
 208  
                                         ex.printStackTrace();
 209  
                                 }
 210  
 
 211  
                                 new SwingDemo();
 212  
                         }
 213  
                 });
 214  
         }
 215  
 
 216  
         public SwingDemo()
 217  
         {
 218  
                 super("MigLayout Swing Demo v2.5 - Mig Layout v" + LayoutUtil.getVersion());
 219  
 
 220  
 //                if (benchRuns > 0)
 221  
 //                        RepaintManager.currentManager(this).setDoubleBufferingEnabled(false);
 222  
 
 223  
                 if (benchRuns == 0) {
 224  
                         sourceTextAreaScroll = createTextAreaScroll("", 5, 80, true);
 225  
                         sourceTextArea = (JTextArea) sourceTextAreaScroll.getViewport().getView();
 226  
                 }
 227  
 
 228  
                 if (DEBUG) {
 229  
                         contentPanel.add(layoutDisplayPanel, BorderLayout.CENTER);
 230  
 //                    contentPanel.add(layoutPickerTabPane, BorderLayout.WEST);
 231  
 //                    contentPanel.add(descriptionTabPane, BorderLayout.SOUTH);
 232  
                 } else {
 233  
                         contentPanel.add(layoutPickerTabPane, "spany,grow");
 234  
                         contentPanel.add(layoutDisplayPanel, "grow");
 235  
                         contentPanel.add(southTabPane, "growx");
 236  
                 }
 237  
 
 238  
                 setContentPane(contentPanel);
 239  
 
 240  
                         pickerList.setOpaque(OPAQUE);
 241  
                         ((DefaultListCellRenderer) pickerList.getCellRenderer()).setOpaque(OPAQUE);
 242  
                         pickerList.setSelectionForeground(new Color(0, 0, 220));
 243  
                         pickerList.setBackground(null);
 244  
                         pickerList.setBorder(new EmptyBorder(2, 5, 0, 4));
 245  
                         pickerList.setFont(pickerList.getFont().deriveFont(Font.BOLD));
 246  
                 layoutPickerTabPane.addTab("Example Browser", pickerList);
 247  
 
 248  
                         descrTextAreaScroll.setBorder(null);
 249  
                         descrTextAreaScroll.setOpaque(OPAQUE);
 250  
                         descrTextAreaScroll.getViewport().setOpaque(OPAQUE);
 251  
                         descrTextArea.setOpaque(OPAQUE);
 252  
                         descrTextArea.setEditable(false);
 253  
                         descrTextArea.setBorder(new EmptyBorder(0, 4, 0, 4));
 254  
                 southTabPane.addTab("Description", descrTextAreaScroll);
 255  
 
 256  
 
 257  
                 if (sourceTextArea != null) {
 258  
                         sourceTextAreaScroll.setBorder(null);
 259  
                         sourceTextAreaScroll.setOpaque(OPAQUE);
 260  
                         sourceTextAreaScroll.getViewport().setOpaque(OPAQUE);
 261  
                         sourceTextAreaScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 262  
                         sourceTextArea.setOpaque(OPAQUE);
 263  
                         sourceTextArea.setLineWrap(false);
 264  
                         sourceTextArea.setWrapStyleWord(false);
 265  
                         sourceTextArea.setEditable(false);
 266  
                         sourceTextArea.setBorder(new EmptyBorder(0, 4, 0, 4));
 267  
                         sourceTextArea.setFont(new Font("monospaced", Font.PLAIN, 11));
 268  
                         southTabPane.addTab("Source Code", sourceTextAreaScroll);
 269  
 
 270  
                         southTabPane.addMouseListener(new MouseAdapter() {
 271  
                                 public void mouseClicked(MouseEvent e)
 272  
                                 {
 273  
                                         if (e.getClickCount() == 2)
 274  
                                                 showSourceInFrame();
 275  
                                 }
 276  
                         });
 277  
                 }
 278  
 
 279  
                 for (int i = 0; i < panels.length; i++)
 280  
                         ((DefaultListModel) pickerList.getModel()).addElement(panels[i][0]);
 281  
 
 282  
                 try {
 283  
                         if (UIManager.getLookAndFeel().getID().equals("Aqua")) {
 284  
                                 setSize(1000, 750);
 285  
                         } else {
 286  
                                 setSize(900, 650);
 287  
                         }
 288  
                         setLocationRelativeTo(null);
 289  
                         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 290  
                         setVisible(true);
 291  
                 } catch(Throwable t) {
 292  
                         t.printStackTrace();
 293  
                         System.exit(1);
 294  
                 }
 295  
 
 296  
                 pickerList.addListSelectionListener(new ListSelectionListener() {
 297  
                         public void valueChanged(ListSelectionEvent e)
 298  
                         {
 299  
                                 int ix = pickerList.getSelectedIndex();
 300  
                                 if (ix == -1 || lastIndex == ix)
 301  
                                         return;
 302  
 
 303  
                                 lastIndex = ix;
 304  
 
 305  
                                 String methodName = "create" + panels[ix][0].replace(' ', '_');
 306  
                                 layoutDisplayPanel.removeAll();
 307  
                                 try {
 308  
                                         pickerList.requestFocusInWindow();
 309  
                                         final JComponent panel = (JComponent) SwingDemo.class.getMethod(methodName, new Class[0]).invoke(SwingDemo.this, new Object[0]);
 310  
                                         layoutDisplayPanel.add(panel);
 311  
                                         descrTextArea.setText(panels[ix][1]);
 312  
                                         descrTextArea.setCaretPosition(0);
 313  
                                         contentPanel.revalidate();
 314  
 
 315  
                                 } catch (Exception e1) {
 316  
                                         e1.printStackTrace();   // Should never happpen...
 317  
                                 }
 318  
                                 southTabPane.setSelectedIndex(0);
 319  
                         }
 320  
                 });
 321  
 
 322  
                 pickerList.requestFocusInWindow();
 323  
                 Toolkit.getDefaultToolkit().setDynamicLayout(true);
 324  
 
 325  
                 if (benchRuns > 0) {
 326  
                         doBenchmark();
 327  
                 } else {
 328  
                         pickerList.setSelectedIndex(INITIAL_INDEX);
 329  
 
 330  
                         KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() {
 331  
                                 public boolean dispatchKeyEvent(KeyEvent e)
 332  
                                 {
 333  
                                         if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_B && (e.getModifiersEx() & KeyEvent.CTRL_DOWN_MASK) > 0) {
 334  
                                                 startupMillis = System.currentTimeMillis();
 335  
                                                 timeToShowMillis = System.currentTimeMillis() - startupMillis;
 336  
                                                 benchRuns = 1;
 337  
                                                 doBenchmark();
 338  
                                                 return true;
 339  
                                         }
 340  
                                         return false;
 341  
                                 }
 342  
                         });
 343  
                 }
 344  
         }
 345  
 
 346  
         private void doBenchmark()
 347  
         {
 348  
                 Thread benchThread = new Thread() {
 349  
                         public void run()
 350  
                         {
 351  
                                 for (int j = 0; j < benchRuns; j++) {
 352  
                                         lastRunTimeStart = System.currentTimeMillis();
 353  
                                         for (int i = 0, iCnt = pickerList.getModel().getSize(); i < iCnt; i++) {
 354  
 
 355  
                                                 if (benchRuns > 0 && panels[i][0].equals("Visual Bounds"))
 356  
                                                         continue;   // the SWT version does not have Visual bounds...
 357  
 
 358  
                                                 final int ii = i;
 359  
                                                 try {
 360  
                                                         SwingUtilities.invokeAndWait(new Runnable() {
 361  
                                                                 public void run() {
 362  
                                                                         pickerList.setSelectedIndex(ii);
 363  
                                                                         Toolkit.getDefaultToolkit().sync();
 364  
                                                                 }
 365  
                                                         });
 366  
                                                 } catch (Exception e) {
 367  
                                                         e.printStackTrace();
 368  
                                                 }
 369  
 
 370  
                                                 Component[] comps = layoutDisplayPanel.getComponents();
 371  
                                                 for (int cIx = 0; cIx < comps.length; cIx++) {
 372  
                                                         if (comps[cIx] instanceof JTabbedPane) {
 373  
                                                                 final JTabbedPane tp = (JTabbedPane) comps[cIx];
 374  
 
 375  
                                                                 for (int k = 0, kCnt = tp.getTabCount(); k < kCnt; k++) {
 376  
                                                                         final int kk = k;
 377  
                                                                         try {
 378  
                                                                                 SwingUtilities.invokeAndWait(new Runnable() {
 379  
                                                                                         public void run() {
 380  
                                                                                                 tp.setSelectedIndex(kk);
 381  
                                                                                                 Toolkit.getDefaultToolkit().sync();
 382  
 
 383  
                                                                                                 if (timeToShowMillis == 0)
 384  
                                                                                                         timeToShowMillis = System.currentTimeMillis() - startupMillis;
 385  
                                                                                         }
 386  
                                                                                 });
 387  
                                                                         } catch (Exception e) {
 388  
                                                                                 e.printStackTrace();
 389  
                                                                         }
 390  
                                                                 }
 391  
                                                         }
 392  
                                                 }
 393  
                                         }
 394  
                                         if (runTimeSB != null) {
 395  
                                            runTimeSB.append("Run ").append(j).append(": ");
 396  
                                            runTimeSB.append(System.currentTimeMillis() - lastRunTimeStart).append(" millis.\n");
 397  
                                         }
 398  
                                 }
 399  
 
 400  
                                 benchRunTime = System.currentTimeMillis() - startupMillis - timeToShowMillis;
 401  
 
 402  
                                 final String message = "Java Version:       " + System.getProperty("java.version") + "\n" +
 403  
                                                  "Look & Feel:        " + UIManager.getLookAndFeel().getDescription() + "\n" +
 404  
                                                  "Time to Show:       " + timeToShowMillis + " millis.\n" +
 405  
                                                  (runTimeSB != null ? runTimeSB.toString() : "") +
 406  
                                                  "Benchmark Run Time: " + benchRunTime + " millis.\n" +
 407  
                                                  "Average Run Time:   " + (benchRunTime / benchRuns) + " millis (" + benchRuns + " runs).\n\n";
 408  
 
 409  
                                 if (benchOutFileName == null) {
 410  
                                         JOptionPane.showMessageDialog(SwingDemo.this, message, "Results", JOptionPane.INFORMATION_MESSAGE);
 411  
                                 } else {
 412  
                                         FileWriter fw = null;
 413  
                                         try {
 414  
                                                 fw = new FileWriter(benchOutFileName, append);
 415  
                                                 fw.write(message);
 416  
                                         } catch(IOException ex) {
 417  
                                                 ex.printStackTrace();
 418  
                                         } finally {
 419  
                                                 if (fw != null)
 420  
                                                         try {fw.close();} catch(IOException ex) {}
 421  
                                         }
 422  
                                 }
 423  
                                 System.out.println(message);
 424  
                         }
 425  
                 };
 426  
                 benchThread.start();
 427  
         }
 428  
 
 429  
         private void setSource(String source)
 430  
         {
 431  
                 if (benchRuns > 0 || sourceTextArea == null)
 432  
                         return;
 433  
 
 434  
                 if (source.length() > 0) {
 435  
                         source = source.replaceAll("\t\t", "");
 436  
                         source = "DOUBLE CLICK TAB TO SHOW SOURCE IN SEPARATE WINDOW!\n===================================================\n\n" + source;
 437  
                 }
 438  
                 sourceTextArea.setText(source);
 439  
                 sourceTextArea.setCaretPosition(0);
 440  
 
 441  
                 if (sourceFrame != null && sourceFrame.isVisible()) {
 442  
                         sourceFrameTextArea.setText(source.length() > 105 ? source.substring(105) : "No Source Code Available!");
 443  
                         sourceFrameTextArea.setCaretPosition(0);
 444  
                 }
 445  
         }
 446  
 
 447  
         private void showSourceInFrame()
 448  
         {
 449  
                 if (sourceTextArea == null)
 450  
                         return;
 451  
 
 452  
                 JScrollPane sourceFrameTextAreaScroll = createTextAreaScroll("", 5, 80, true);
 453  
                 sourceFrameTextArea = (JTextArea) sourceFrameTextAreaScroll.getViewport().getView();
 454  
 
 455  
                 sourceFrameTextAreaScroll.setBorder(null);
 456  
                 sourceFrameTextAreaScroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
 457  
                 sourceFrameTextArea.setLineWrap(false);
 458  
                 sourceFrameTextArea.setWrapStyleWord(false);
 459  
                 sourceFrameTextArea.setEditable(false);
 460  
                 sourceFrameTextArea.setBorder(new EmptyBorder(10, 10, 10, 10));
 461  
                 sourceFrameTextArea.setFont(new Font("monospaced", Font.PLAIN, 12));
 462  
 
 463  
                 String source = this.sourceTextArea.getText();
 464  
                 sourceFrameTextArea.setText(source.length() > 105 ? source.substring(105) : "No Source Code Available!");
 465  
                 sourceFrameTextArea.setCaretPosition(0);
 466  
 
 467  
                 sourceFrame = new JFrame("Source Code");
 468  
                 sourceFrame.getContentPane().add(sourceFrameTextAreaScroll, BorderLayout.CENTER);
 469  
                 sourceFrame.setSize(700, 800);
 470  
                 sourceFrame.setLocationRelativeTo(this);
 471  
                 sourceFrame.setVisible(true);
 472  
         }
 473  
 
 474  
         public JComponent createTest()
 475  
         {
 476  
                 JPanel thisp = new JPanel();
 477  
 
 478  
                 MigLayout layout = new MigLayout();
 479  
                 thisp.setLayout(layout);
 480  
 
 481  
 //                thisp.add("wrap, span", new JButton());
 482  
 //                thisp.add("newline, span", new JButton());
 483  
 //                thisp.add("newline, span", new JButton());
 484  
 //                thisp.add("newline, span", new JButton());
 485  
 
 486  
 //                thisp.add("newline 100", new JButton("should have 40 pixels before"));
 487  
 
 488  
 //                thisp.add("newline", new JButton());
 489  
 //                thisp.add("newline", new JButton());
 490  
 //                thisp.add("newline", new JButton());
 491  
 
 492  
                 return thisp;
 493  
         }
 494  
 
 495  
         public JComponent createAPI_Constraints1()
 496  
         {
 497  
                 JTabbedPane tabbedPane = new JTabbedPane();
 498  
 
 499  
                 LC layC = new LC().fill().wrap();
 500  
                 AC colC = new AC().align("right", 1).fill(2, 4).grow(100, 2, 4).align("right", 3).gap("15", 2);
 501  
                 AC rowC = new AC().align("top", 7).gap("15!", 6).grow(100, 8);
 502  
 
 503  
                 JPanel panel = createTabPanel(new MigLayout(layC, colC, rowC));    // Makes the background gradient
 504  
 
 505  
                 // References to text fields not stored to reduce code clutter.
 506  
 
 507  
                 JScrollPane list2 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));
 508  
                 panel.add(list2,                     new CC().spanY().growY().minWidth("150").gapX(null, "10"));
 509  
 
 510  
                 panel.add(new JLabel("Last Name"));
 511  
                 panel.add(new JTextField());
 512  
                 panel.add(new JLabel("First Name"));
 513  
                 panel.add(new JTextField(),          new CC().wrap().alignX("right"));
 514  
                 panel.add(new JLabel("Phone"));
 515  
                 panel.add(new JTextField());
 516  
                 panel.add(new JLabel("Email"));
 517  
                 panel.add(new JTextField());
 518  
                 panel.add(new JLabel("Address 1"));
 519  
                 panel.add(new JTextField(),          new CC().spanX().growX());
 520  
                 panel.add(new JLabel("Address 2"));
 521  
                 panel.add(new JTextField(),          new CC().spanX().growX());
 522  
                 panel.add(new JLabel("City"));
 523  
                 panel.add(new JTextField(),          new CC().wrap());
 524  
                 panel.add(new JLabel("State"));
 525  
                 panel.add(new JTextField());
 526  
                 panel.add(new JLabel("Postal Code"));
 527  
                 panel.add(new JTextField(10),        new CC().spanX(2).growX(0));
 528  
                 panel.add(new JLabel("Country"));
 529  
                 panel.add(new JTextField(),          new CC().wrap());
 530  
 
 531  
                 panel.add(new JButton("New"),        new CC().spanX(5).split(5).tag("other"));
 532  
                 panel.add(new JButton("Delete"),     new CC().tag("other"));
 533  
                 panel.add(new JButton("Edit"),       new CC().tag("other"));
 534  
                 panel.add(new JButton("Save"),       new CC().tag("other"));
 535  
                 panel.add(new JButton("Cancel"),     new CC().tag("cancel"));
 536  
 
 537  
                 tabbedPane.addTab("Layout Showdown (improved)", panel);
 538  
 
 539  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 540  
                           "\n" +
 541  
                           "LC layC = new LC().fill().wrap();\n" +
 542  
                           "AC colC = new AC().align(\"right\", 1).fill(2, 4).grow(100, 2, 4).align(\"right\", 3).gap(\"15\", 2);\n" +
 543  
                           "AC rowC = new AC().align(\"top\", 7).gap(\"15!\", 6).grow(100, 8);\n" +
 544  
                           "\n" +
 545  
                           "JPanel panel = createTabPanel(new MigLayout(layC, colC, rowC));    // Makes the background gradient\n" +
 546  
                           "\n" +
 547  
                           "// References to text fields not stored to reduce code clutter.\n" +
 548  
                           "\n" +
 549  
                           "JScrollPane list2 = new JScrollPane(new JList(new String[] {\"Mouse, Mickey\"}));\n" +
 550  
                           "panel.add(list2,                     new CC().spanY().growY().minWidth(\"150\").gapX(null, \"10\"));\n" +
 551  
                           "\n" +
 552  
                           "panel.add(new JLabel(\"Last Name\"));\n" +
 553  
                           "panel.add(new JTextField());\n" +
 554  
                           "panel.add(new JLabel(\"First Name\"));\n" +
 555  
                           "panel.add(new JTextField(),          new CC().wrap().alignX(\"right\"));\n" +
 556  
                           "panel.add(new JLabel(\"Phone\"));\n" +
 557  
                           "panel.add(new JTextField());\n" +
 558  
                           "panel.add(new JLabel(\"Email\"));\n" +
 559  
                           "panel.add(new JTextField());\n" +
 560  
                           "panel.add(new JLabel(\"Address 1\"));\n" +
 561  
                           "panel.add(new JTextField(),          new CC().spanX().growX());\n" +
 562  
                           "panel.add(new JLabel(\"Address 2\"));\n" +
 563  
                           "panel.add(new JTextField(),          new CC().spanX().growX());\n" +
 564  
                           "panel.add(new JLabel(\"City\"));\n" +
 565  
                           "panel.add(new JTextField(),          new CC().wrap());\n" +
 566  
                           "panel.add(new JLabel(\"State\"));\n" +
 567  
                           "panel.add(new JTextField());\n" +
 568  
                           "panel.add(new JLabel(\"Postal Code\"));\n" +
 569  
                           "panel.add(new JTextField(10),        new CC().spanX(2).growX(0));\n" +
 570  
                           "panel.add(new JLabel(\"Country\"));\n" +
 571  
                           "panel.add(new JTextField(),          new CC().wrap());\n" +
 572  
                           "\n" +
 573  
                           "panel.add(new JButton(\"New\"),        new CC().spanX(5).split(5).tag(\"other\"));\n" +
 574  
                           "panel.add(new JButton(\"Delete\"),     new CC().tag(\"other\"));\n" +
 575  
                           "panel.add(new JButton(\"Edit\"),       new CC().tag(\"other\"));\n" +
 576  
                           "panel.add(new JButton(\"Save\"),       new CC().tag(\"other\"));\n" +
 577  
                           "panel.add(new JButton(\"Cancel\"),     new CC().tag(\"cancel\"));\n" +
 578  
                           "\n" +
 579  
                           "tabbedPane.addTab(\"Layout Showdown (improved)\", panel);");
 580  
 
 581  
                 return tabbedPane;
 582  
         }
 583  
 
 584  
         public JComponent createAPI_Constraints2()
 585  
         {
 586  
                 JTabbedPane tabbedPane = new JTabbedPane();
 587  
 
 588  
                 LC layC = new LC().fill().wrap();
 589  
                 AC colC = new AC().align("right", 0).fill(1, 3).grow(100, 1, 3).align("right", 2).gap("15", 1);
 590  
                 AC rowC = new AC().index(6).gap("15!").align("top").grow(100, 8);
 591  
 
 592  
                 JPanel panel = createTabPanel(new MigLayout(layC, colC, rowC));    // Makes the background gradient
 593  
 
 594  
                 // References to text fields not stored to reduce code clutter.
 595  
 
 596  
                 panel.add(new JLabel("Last Name"));
 597  
                 panel.add(new JTextField());
 598  
                 panel.add(new JLabel("First Name"));
 599  
                 panel.add(new JTextField(),          new CC().wrap());
 600  
                 panel.add(new JLabel("Phone"));
 601  
                 panel.add(new JTextField());
 602  
                 panel.add(new JLabel("Email"));
 603  
                 panel.add(new JTextField());
 604  
                 panel.add(new JLabel("Address 1"));
 605  
                 panel.add(new JTextField(),          new CC().spanX().growX());
 606  
                 panel.add(new JLabel("Address 2"));
 607  
                 panel.add(new JTextField(),          new CC().spanX().growX());
 608  
                 panel.add(new JLabel("City"));
 609  
                 panel.add(new JTextField(),          new CC().wrap());
 610  
                 panel.add(new JLabel("State"));
 611  
                 panel.add(new JTextField());
 612  
                 panel.add(new JLabel("Postal Code"));
 613  
                 panel.add(new JTextField(10),        new CC().spanX(2).growX(0));
 614  
                 panel.add(new JLabel("Country"));
 615  
                 panel.add(new JTextField(),          new CC().wrap());
 616  
 
 617  
                 panel.add(createButton("New"),        new CC().spanX(5).split(5).tag("other"));
 618  
                 panel.add(createButton("Delete"),     new CC().tag("other"));
 619  
                 panel.add(createButton("Edit"),       new CC().tag("other"));
 620  
                 panel.add(createButton("Save"),       new CC().tag("other"));
 621  
                 panel.add(createButton("Cancel"),     new CC().tag("cancel"));
 622  
 
 623  
                 tabbedPane.addTab("Layout Showdown (improved)", panel);
 624  
 
 625  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 626  
                           "\n" +
 627  
                           "LC layC = new LC().fill().wrap();\n" +
 628  
                           "AC colC = new AC().align(\"right\", 0).fill(1, 3).grow(100, 1, 3).align(\"right\", 2).gap(\"15\", 1);\n" +
 629  
                           "AC rowC = new AC().index(6).gap(\"15!\").align(\"top\").grow(100, 8);\n" +
 630  
                           "\n" +
 631  
                           "JPanel panel = createTabPanel(new MigLayout(layC, colC, rowC));    // Makes the background gradient\n" +
 632  
                           "\n" +
 633  
                           "// References to text fields not stored to reduce code clutter.\n" +
 634  
                           "\n" +
 635  
                           "panel.add(new JLabel(\"Last Name\"));\n" +
 636  
                           "panel.add(new JTextField());\n" +
 637  
                           "panel.add(new JLabel(\"First Name\"));\n" +
 638  
                           "panel.add(new JTextField(),          new CC().wrap());\n" +
 639  
                           "panel.add(new JLabel(\"Phone\"));\n" +
 640  
                           "panel.add(new JTextField());\n" +
 641  
                           "panel.add(new JLabel(\"Email\"));\n" +
 642  
                           "panel.add(new JTextField());\n" +
 643  
                           "panel.add(new JLabel(\"Address 1\"));\n" +
 644  
                           "panel.add(new JTextField(),          new CC().spanX().growX());\n" +
 645  
                           "panel.add(new JLabel(\"Address 2\"));\n" +
 646  
                           "panel.add(new JTextField(),          new CC().spanX().growX());\n" +
 647  
                           "panel.add(new JLabel(\"City\"));\n" +
 648  
                           "panel.add(new JTextField(),          new CC().wrap());\n" +
 649  
                           "panel.add(new JLabel(\"State\"));\n" +
 650  
                           "panel.add(new JTextField());\n" +
 651  
                           "panel.add(new JLabel(\"Postal Code\"));\n" +
 652  
                           "panel.add(new JTextField(10),        new CC().spanX(2).growX(0));\n" +
 653  
                           "panel.add(new JLabel(\"Country\"));\n" +
 654  
                           "panel.add(new JTextField(),          new CC().wrap());\n" +
 655  
                           "\n" +
 656  
                           "panel.add(createButton(\"New\"),        new CC().spanX(5).split(5).tag(\"other\"));\n" +
 657  
                           "panel.add(createButton(\"Delete\"),     new CC().tag(\"other\"));\n" +
 658  
                           "panel.add(createButton(\"Edit\"),       new CC().tag(\"other\"));\n" +
 659  
                           "panel.add(createButton(\"Save\"),       new CC().tag(\"other\"));\n" +
 660  
                           "panel.add(createButton(\"Cancel\"),     new CC().tag(\"cancel\"));\n" +
 661  
                           "\n" +
 662  
                           "tabbedPane.addTab(\"Layout Showdown (improved)\", panel);");
 663  
 
 664  
                 return tabbedPane;
 665  
         }
 666  
 
 667  
         public JComponent createLayout_Showdown()
 668  
         {
 669  
                 JTabbedPane tabbedPane = new JTabbedPane();
 670  
 
 671  
                 JPanel p = createTabPanel(new MigLayout("", "[]15[][grow,fill]15[grow]"));
 672  
 
 673  
                 JScrollPane list1 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));
 674  
 
 675  
                 p.add(list1,                     "spany, growy, wmin 150");
 676  
                 p.add(new JLabel("Last Name"));
 677  
                 p.add(new JTextField());
 678  
                 p.add(new JLabel("First Name"),  "split");  // split divides the cell
 679  
                 p.add(new JTextField(),          "growx, wrap");
 680  
                 p.add(new JLabel("Phone"));
 681  
                 p.add(new JTextField());
 682  
                 p.add(new JLabel("Email"),       "split");
 683  
                 p.add(new JTextField(),          "growx, wrap");
 684  
                 p.add(new JLabel("Address 1"));
 685  
                 p.add(new JTextField(),          "span, growx"); // span merges cells
 686  
                 p.add(new JLabel("Address 2"));
 687  
                 p.add(new JTextField(),          "span, growx");
 688  
                 p.add(new JLabel("City"));
 689  
                 p.add(new JTextField(),          "wrap"); // wrap continues on next line
 690  
                 p.add(new JLabel("State"));
 691  
                 p.add(new JTextField());
 692  
                 p.add(new JLabel("Postal Code"), "split");
 693  
                 p.add(new JTextField(),          "growx, wrap");
 694  
                 p.add(new JLabel("Country"));
 695  
                 p.add(new JTextField(),          "wrap 15");
 696  
 
 697  
                 p.add(createButton("New"),        "span, split, align left");
 698  
                 p.add(createButton("Delete"),     "");
 699  
                 p.add(createButton("Edit"),       "");
 700  
                 p.add(createButton("Save"),       "");
 701  
                 p.add(createButton("Cancel"),     "wrap push");
 702  
 
 703  
                 tabbedPane.addTab("Layout Showdown (pure)", p);
 704  
 
 705  
 
 706  
                 // Fixed version *******************************************
 707  
 
 708  
                 JPanel p2 = createTabPanel(new MigLayout("", "[]15[][grow,fill]15[][grow,fill]"));    // Makes the background gradient
 709  
 
 710  
                 // References to text fields not stored to reduce code clutter.
 711  
 
 712  
                 JScrollPane list2 = new JScrollPane(new JList(new String[] {"Mouse, Mickey"}));
 713  
                 p2.add(list2,                     "spany, growy, wmin 150");
 714  
                 p2.add(new JLabel("Last Name"));
 715  
                 p2.add(new JTextField());
 716  
                 p2.add(new JLabel("First Name"));
 717  
                 p2.add(new JTextField(),          "wrap");
 718  
                 p2.add(new JLabel("Phone"));
 719  
                 p2.add(new JTextField());
 720  
                 p2.add(new JLabel("Email"));
 721  
                 p2.add(new JTextField(),          "wrap");
 722  
                 p2.add(new JLabel("Address 1"));
 723  
                 p2.add(new JTextField(),          "span");
 724  
                 p2.add(new JLabel("Address 2"));
 725  
                 p2.add(new JTextField(),          "span");
 726  
                 p2.add(new JLabel("City"));
 727  
                 p2.add(new JTextField(),          "wrap");
 728  
                 p2.add(new JLabel("State"));
 729  
                 p2.add(new JTextField());
 730  
                 p2.add(new JLabel("Postal Code"));
 731  
                 p2.add(new JTextField(10),        "growx 0, wrap");
 732  
                 p2.add(new JLabel("Country"));
 733  
                 p2.add(new JTextField(),          "wrap 15");
 734  
 
 735  
                 p2.add(createButton("New"),        "tag other, span, split");
 736  
                 p2.add(createButton("Delete"),     "tag other");
 737  
                 p2.add(createButton("Edit"),       "tag other");
 738  
                 p2.add(createButton("Save"),       "tag other");
 739  
                 p2.add(createButton("Cancel"),     "tag cancel, wrap push");
 740  
 
 741  
                 tabbedPane.addTab("Layout Showdown (improved)", p2);
 742  
 
 743  
 
 744  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 745  
                           "\n" +
 746  
                           "JPanel p = createTabPanel(new MigLayout(\"\", \"[]15[][grow,fill]15[grow]\"));\n" +
 747  
                           "\n" +
 748  
                           "JScrollPane list1 = new JScrollPane(new JList(new String[] {\"Mouse, Mickey\"}));\n" +
 749  
                           "\n" +
 750  
                           "p.add(list1,                     \"spany, growy, wmin 150\");\n" +
 751  
                           "p.add(new JLabel(\"Last Name\"));\n" +
 752  
                           "p.add(new JTextField());\n" +
 753  
                           "p.add(new JLabel(\"First Name\"),  \"split\");  // split divides the cell\n" +
 754  
                           "p.add(new JTextField(),          \"growx, wrap\");\n" +
 755  
                           "p.add(new JLabel(\"Phone\"));\n" +
 756  
                           "p.add(new JTextField());\n" +
 757  
                           "p.add(new JLabel(\"Email\"),       \"split\");\n" +
 758  
                           "p.add(new JTextField(),          \"growx, wrap\");\n" +
 759  
                           "p.add(new JLabel(\"Address 1\"));\n" +
 760  
                           "p.add(new JTextField(),          \"span, growx\"); // span merges cells\n" +
 761  
                           "p.add(new JLabel(\"Address 2\"));\n" +
 762  
                           "p.add(new JTextField(),          \"span, growx\");\n" +
 763  
                           "p.add(new JLabel(\"City\"));\n" +
 764  
                           "p.add(new JTextField(),          \"wrap\"); // wrap continues on next line\n" +
 765  
                           "p.add(new JLabel(\"State\"));\n" +
 766  
                           "p.add(new JTextField());\n" +
 767  
                           "p.add(new JLabel(\"Postal Code\"), \"split\");\n" +
 768  
                           "p.add(new JTextField(),          \"growx, wrap\");\n" +
 769  
                           "p.add(new JLabel(\"Country\"));\n" +
 770  
                           "p.add(new JTextField(),          \"wrap 15\");\n" +
 771  
                           "\n" +
 772  
                           "p.add(createButton(\"New\"),        \"span, split, align left\");\n" +
 773  
                           "p.add(createButton(\"Delete\"),     \"\");\n" +
 774  
                           "p.add(createButton(\"Edit\"),       \"\");\n" +
 775  
                           "p.add(createButton(\"Save\"),       \"\");\n" +
 776  
                           "p.add(createButton(\"Cancel\"),     \"wrap push\");\n" +
 777  
                           "\n" +
 778  
                           "tabbedPane.addTab(\"Layout Showdown (pure)\", p);" +
 779  
                           "\n" +
 780  
                           "\t\t// Fixed version *******************************************\n" +
 781  
                           "JPanel p2 = createTabPanel(new MigLayout(\"\", \"[]15[][grow,fill]15[][grow,fill]\"));    // Makes the background gradient\n" +
 782  
                           "\n" +
 783  
                           "// References to text fields not stored to reduce code clutter.\n" +
 784  
                           "\n" +
 785  
                           "JScrollPane list2 = new JScrollPane(new JList(new String[] {\"Mouse, Mickey\"}));\n" +
 786  
                           "p2.add(list2,                     \"spany, growy, wmin 150\");\n" +
 787  
                           "p2.add(new JLabel(\"Last Name\"));\n" +
 788  
                           "p2.add(new JTextField());\n" +
 789  
                           "p2.add(new JLabel(\"First Name\"));\n" +
 790  
                           "p2.add(new JTextField(),          \"wrap\");\n" +
 791  
                           "p2.add(new JLabel(\"Phone\"));\n" +
 792  
                           "p2.add(new JTextField());\n" +
 793  
                           "p2.add(new JLabel(\"Email\"));\n" +
 794  
                           "p2.add(new JTextField(),          \"wrap\");\n" +
 795  
                           "p2.add(new JLabel(\"Address 1\"));\n" +
 796  
                           "p2.add(new JTextField(),          \"span\");\n" +
 797  
                           "p2.add(new JLabel(\"Address 2\"));\n" +
 798  
                           "p2.add(new JTextField(),          \"span\");\n" +
 799  
                           "p2.add(new JLabel(\"City\"));\n" +
 800  
                           "p2.add(new JTextField(),          \"wrap\");\n" +
 801  
                           "p2.add(new JLabel(\"State\"));\n" +
 802  
                           "p2.add(new JTextField());\n" +
 803  
                           "p2.add(new JLabel(\"Postal Code\"));\n" +
 804  
                           "p2.add(new JTextField(10),        \"growx 0, wrap\");\n" +
 805  
                           "p2.add(new JLabel(\"Country\"));\n" +
 806  
                           "p2.add(new JTextField(),          \"wrap 15\");\n" +
 807  
                           "\n" +
 808  
                           "p2.add(createButton(\"New\"),        \"tag other, span, split\");\n" +
 809  
                           "p2.add(createButton(\"Delete\"),     \"tag other\");\n" +
 810  
                           "p2.add(createButton(\"Edit\"),       \"tag other\");\n" +
 811  
                           "p2.add(createButton(\"Save\"),       \"tag other\");\n" +
 812  
                           "p2.add(createButton(\"Cancel\"),     \"tag cancel, wrap push\");\n" +
 813  
                           "\n" +
 814  
                           "tabbedPane.addTab(\"Layout Showdown (improved)\", p2);");
 815  
 
 816  
                 return tabbedPane;
 817  
         }
 818  
 
 819  
         public JComponent createWelcome()
 820  
         {
 821  
                 JTabbedPane tabbedPane = new JTabbedPane();
 822  
 
 823  
                 MigLayout lm = new MigLayout("ins 20, fill", "", "[grow]unrel[]");
 824  
 
 825  
                 JPanel mainPanel = createTabPanel(lm);
 826  
 
 827  
                 String s = "MigLayout's main purpose is to make layouts for SWT and Swing, and possibly other frameworks, much more powerful and a lot easier to create, especially for manual coding.\n\n" +
 828  
                            "The motto is: \"MigLayout makes complex layouts easy and normal layouts one-liners.\"\n\n" +
 829  
                            "The layout engine is very flexible and advanced, something that is needed to make it simple to use yet handle almost all layout use-cases.\n\n" +
 830  
                            "MigLayout can handle all layouts that the commonly used Swing Layout Managers can handle and this with a lot of extra features. " +
 831  
                            "It also incorporates most, if not all, of the open source alternatives FormLayout's and TableLayout's functionality." +
 832  
                            "\n\n\nThanks to Karsten Lentzsch of JGoodies.com for allowing the reuse of the main demo application layout and for his inspiring talks that led to this layout Manager." +
 833  
                            "\n\n\nMikael Grev\n" +
 834  
                            "MiG InfoCom AB\n" +
 835  
                            "miglayout@miginfocom.com";
 836  
 
 837  
                 JTextArea textArea = new JTextArea(s);
 838  
                 textArea.setEditable(false);
 839  
                 textArea.setSize(400, 400);
 840  
 
 841  
                 if (PlatformDefaults.getCurrentPlatform() == PlatformDefaults.WINDOWS_XP)
 842  
                         textArea.setFont(new Font("tahoma", Font.BOLD, 11));
 843  
 
 844  
                 textArea.setOpaque(OPAQUE);
 845  
                 textArea.setWrapStyleWord(true);
 846  
                 textArea.setLineWrap(true);
 847  
 
 848  
                 JLabel label = new JLabel("You can Right Click any Component or Container to change the constraints for it!");
 849  
                 label.setForeground(new Color(200, 0, 0));
 850  
 
 851  
                 mainPanel.add(textArea, "wmin 500, ay top, grow, push, wrap");
 852  
                 mainPanel.add(label, "growx");
 853  
                 label.setFont(label.getFont().deriveFont(Font.BOLD));
 854  
 
 855  
                 tabbedPane.addTab("Welcome", mainPanel);
 856  
 
 857  
                 setSource("");
 858  
 
 859  
                 return tabbedPane;
 860  
         }
 861  
 
 862  
         public JComponent createVisual_Bounds()
 863  
         {
 864  
                 JTabbedPane tabbedPane = new JTabbedPane();
 865  
 
 866  
                 // "NON"-corrected bounds
 867  
                 JPanel p1 = createTabPanel(new MigLayout("fill, ins 3, novisualpadding"));
 868  
                 p1.setBorder(new LineBorder(Color.BLACK));
 869  
 
 870  
                 JTabbedPane demoPane2 = new JTabbedPane();
 871  
                 JPanel demoPanel2 = new JPanel();
 872  
                 demoPanel2.setBackground(Color.WHITE);
 873  
                 demoPane2.addTab("Demo Tab", demoPanel2);
 874  
 
 875  
                 p1.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");
 876  
                 p1.add(demoPane2, "grow, aligny bottom");
 877  
                 p1.add(createTextField("A JTextField", 100), "grow, aligny bottom, wmin 100");
 878  
                 p1.add(createTextArea("A JTextArea", 1, 100), "newline,grow, aligny bottom, wmin 100");
 879  
                 p1.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");
 880  
                 p1.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");
 881  
 
 882  
                 JPanel p2 = createTabPanel(new MigLayout("center,center,fill,ins 3"));
 883  
                 p2.setBorder(new LineBorder(Color.BLACK));
 884  
 
 885  
                 JTabbedPane demoPane = new JTabbedPane();
 886  
                 JPanel demoPanel = new JPanel();
 887  
                 demoPanel.setBackground(Color.WHITE);
 888  
                 demoPane.addTab("Demo Tab", demoPanel);
 889  
 
 890  
                 p2.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");
 891  
                 p2.add(demoPane, "grow, aligny bottom");
 892  
                 p2.add(createTextField("A JTextField", 100), "grow, aligny bottom, wmin 100");
 893  
                 p2.add(createTextArea("A JTextArea", 1, 100), "newline,grow, aligny bottom, wmin 100");
 894  
                 p2.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");
 895  
                 p2.add(createTextArea("A JTextArea", 1, 100), "grow, aligny bottom, wmin 100");
 896  
 
 897  
                 tabbedPane.addTab("Visual Bounds (Not Corrected)", p1);
 898  
                 tabbedPane.addTab("Visual Bounds (Corrected on XP)", p2);
 899  
 
 900  
                 // Disregard. Just forgetting the source code text close to the source code.
 901  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 902  
                           "\n" +
 903  
                           "// \"NON\"-corrected bounds\n" +
 904  
                           "JPanel p1 = createTabPanel(new MigLayout(\"fill, ins 3, novisualpadding\"));\n" +
 905  
                           "p1.setBorder(new LineBorder(Color.BLACK));\n" +
 906  
                           "\n" +
 907  
                           "JTabbedPane demoPane2 = new JTabbedPane();\n" +
 908  
                           "JPanel demoPanel2 = new JPanel();\n" +
 909  
                           "demoPanel2.setBackground(Color.WHITE);\n" +
 910  
                           "demoPane2.addTab(\"Demo Tab\", demoPanel2);\n" +
 911  
                           "\n" +
 912  
                           "p1.add(createTextArea(\"A JTextArea\", 1, 100), \"grow, aligny bottom, wmin 100\");\n" +
 913  
                           "p1.add(demoPane2, \"grow, aligny bottom\");\n" +
 914  
                           "p1.add(createTextField(\"A JTextField\", 100), \"grow, aligny bottom, wmin 100\");\n" +
 915  
                           "p1.add(createTextArea(\"A JTextArea\", 1, 100), \"newline,grow, aligny bottom, wmin 100\");\n" +
 916  
                           "p1.add(createTextArea(\"A JTextArea\", 1, 100), \"grow, aligny bottom, wmin 100\");\n" +
 917  
                           "p1.add(createTextArea(\"A JTextArea\", 1, 100), \"grow, aligny bottom, wmin 100\");\n" +
 918  
                           "\n" +
 919  
                           "JPanel p2 = createTabPanel(new MigLayout(\"center,center,fill,ins 3\"));\n" +
 920  
                           "p2.setBorder(new LineBorder(Color.BLACK));\n" +
 921  
                           "\n" +
 922  
                           "JTabbedPane demoPane = new JTabbedPane();\n" +
 923  
                           "JPanel demoPanel = new JPanel();\n" +
 924  
                           "demoPanel.setBackground(Color.WHITE);\n" +
 925  
                           "demoPane.addTab(\"Demo Tab\", demoPanel);\n" +
 926  
                           "\n" +
 927  
                           "p2.add(createTextArea(\"A JTextArea\", 1, 100), \"grow, aligny bottom, wmin 100\");\n" +
 928  
                           "p2.add(demoPane, \"grow, aligny bottom\");\n" +
 929  
                           "p2.add(createTextField(\"A JTextField\", 100), \"grow, aligny bottom, wmin 100\");\n" +
 930  
                           "p2.add(createTextArea(\"A JTextArea\", 1, 100), \"newline,grow, aligny bottom, wmin 100\");\n" +
 931  
                           "p2.add(createTextArea(\"A JTextArea\", 1, 100), \"grow, aligny bottom, wmin 100\");\n" +
 932  
                           "p2.add(createTextArea(\"A JTextArea\", 1, 100), \"grow, aligny bottom, wmin 100\");\n" +
 933  
                           "\n" +
 934  
                           "tabbedPane.addTab(\"Visual Bounds (Not Corrected)\", p1);\n" +
 935  
                           "tabbedPane.addTab(\"Visual Bounds (Corrected on XP)\", p2);");
 936  
 
 937  
                 return tabbedPane;
 938  
         }
 939  
 
 940  
         public JComponent createDocking()
 941  
         {
 942  
                 JTabbedPane tabbedPane = new JTabbedPane();
 943  
 
 944  
                 JPanel p1 = createTabPanel(new MigLayout("fill"));
 945  
 
 946  
                 p1.add(createPanel("1. North"), "north");
 947  
                 p1.add(createPanel("2. West"), "west");
 948  
                 p1.add(createPanel("3. East"), "east");
 949  
                 p1.add(createPanel("4. South"), "south");
 950  
 
 951  
                 String[][] data = new String[20][6];
 952  
                 for (int r = 0; r < data.length; r++) {
 953  
                         data[r] = new String[6];
 954  
                         for (int c = 0; c < data[r].length; c++)
 955  
                                 data[r][c] = "Cell " + (r + 1) + ", " + (c + 1);
 956  
                 }
 957  
                 JTable table = new JTable(data, new String[] {"Column 1", "Column 2", "Column 3", "Column 4", "Column 5", "Column 6"});
 958  
                 p1.add(new JScrollPane(table), "grow");
 959  
 
 960  
                 JPanel p2 = createTabPanel(new MigLayout("fill", "[c]", ""));
 961  
 
 962  
                 p2.add(createPanel("1. North"), "north");
 963  
                 p2.add(createPanel("2. North"), "north");
 964  
                 p2.add(createPanel("3. West"), "west");
 965  
                 p2.add(createPanel("4. West"), "west");
 966  
                 p2.add(createPanel("5. South"), "south");
 967  
                 p2.add(createPanel("6. East"), "east");
 968  
                 p2.add(createButton("7. Normal"));
 969  
                 p2.add(createButton("8. Normal"));
 970  
                 p2.add(createButton("9. Normal"));
 971  
 
 972  
                 JPanel p3 = createTabPanel(new MigLayout());
 973  
 
 974  
                 p3.add(createPanel("1. North"), "north");
 975  
                 p3.add(createPanel("2. South"), "south");
 976  
                 p3.add(createPanel("3. West"), "west");
 977  
                 p3.add(createPanel("4. East"), "east");
 978  
                 p3.add(createButton("5. Normal"));
 979  
 
 980  
                 JPanel p4 = createTabPanel(new MigLayout());
 981  
 
 982  
                 p4.add(createPanel("1. North"), "north");
 983  
                 p4.add(createPanel("2. North"), "north");
 984  
                 p4.add(createPanel("3. West"), "west");
 985  
                 p4.add(createPanel("4. West"), "west");
 986  
                 p4.add(createPanel("5. South"), "south");
 987  
                 p4.add(createPanel("6. East"), "east");
 988  
                 p4.add(createButton("7. Normal"));
 989  
                 p4.add(createButton("8. Normal"));
 990  
                 p4.add(createButton("9. Normal"));
 991  
 
 992  
                 JPanel p5 = createTabPanel(new MigLayout("fillx", "[c]", ""));
 993  
 
 994  
                 p5.add(createPanel("1. North"), "north");
 995  
                 p5.add(createPanel("2. North"), "north");
 996  
                 p5.add(createPanel("3. West"), "west");
 997  
                 p5.add(createPanel("4. West"), "west");
 998  
                 p5.add(createPanel("5. South"), "south");
 999  
                 p5.add(createPanel("6. East"), "east");
 1000  
                 p5.add(createButton("7. Normal"));
 1001  
                 p5.add(createButton("8. Normal"));
 1002  
                 p5.add(createButton("9. Normal"));
 1003  
 
 1004  
                 JPanel p6 = createTabPanel(new MigLayout("fill", "", ""));
 1005  
 
 1006  
                 Random rand = new Random();
 1007  
                 String[] sides = {"north", "east", "south", "west"};
 1008  
                 for (int i = 0; i < 20; i++) {
 1009  
                         int side = rand.nextInt(4);
 1010  
                         p6.add(createPanel((i + 1) + " " + sides[side]), sides[side]);
 1011  
                 }
 1012  
                 p6.add(createPanel("I'm in the Center!"), "dock center");
 1013  
 
 1014  
                 tabbedPane.addTab("Docking 1 (fill)", p1);
 1015  
                 tabbedPane.addTab("Docking 2 (fill)", p2);
 1016  
                 tabbedPane.addTab("Docking 3", p3);
 1017  
                 tabbedPane.addTab("Docking 4", p4);
 1018  
                 tabbedPane.addTab("Docking 5 (fillx)", p5);
 1019  
                 tabbedPane.addTab("Random Docking", new JScrollPane(p6));
 1020  
 
 1021  
                 // Disregard. Just forgetting the source code text close to the source code.
 1022  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 1023  
                           "\n" +
 1024  
                           "JPanel p1 = createTabPanel(new MigLayout(\"fill\"));\n" +
 1025  
                           "\n" +
 1026  
                           "p1.add(createPanel(\"1. North\"), \"north\");\n" +
 1027  
                           "p1.add(createPanel(\"2. West\"), \"west\");\n" +
 1028  
                           "p1.add(createPanel(\"3. East\"), \"east\");\n" +
 1029  
                           "p1.add(createPanel(\"4. South\"), \"south\");\n" +
 1030  
                           "\n" +
 1031  
                           "String[][] data = new String[20][6];\n" +
 1032  
                           "for (int r = 0; r < data.length; r++) {\n" +
 1033  
                           "\tdata[r] = new String[6];\n" +
 1034  
                           "\tfor (int c = 0; c < data[r].length; c++)\n" +
 1035  
                           "\t\tdata[r][c] = \"Cell \" + (r + 1) + \", \" + (c + 1);\n" +
 1036  
                           "}\n" +
 1037  
                           "JTable table = new JTable(data, new String[] {\"Column 1\", \"Column 2\", \"Column 3\", \"Column 4\", \"Column 5\", \"Column 6\"});\n" +
 1038  
                           "p1.add(new JScrollPane(table), \"grow\");\n" +
 1039  
                           "\n" +
 1040  
                           "JPanel p2 = createTabPanel(new MigLayout(\"fill\", \"[c]\", \"\"));\n" +
 1041  
                           "\n" +
 1042  
                           "p2.add(createPanel(\"1. North\"), \"north\");\n" +
 1043  
                           "p2.add(createPanel(\"2. North\"), \"north\");\n" +
 1044  
                           "p2.add(createPanel(\"3. West\"), \"west\");\n" +
 1045  
                           "p2.add(createPanel(\"4. West\"), \"west\");\n" +
 1046  
                           "p2.add(createPanel(\"5. South\"), \"south\");\n" +
 1047  
                           "p2.add(createPanel(\"6. East\"), \"east\");\n" +
 1048  
                           "p2.add(createButton(\"7. Normal\"));\n" +
 1049  
                           "p2.add(createButton(\"8. Normal\"));\n" +
 1050  
                           "p2.add(createButton(\"9. Normal\"));\n" +
 1051  
                           "\n" +
 1052  
                           "JPanel p3 = createTabPanel(new MigLayout());\n" +
 1053  
                           "\n" +
 1054  
                           "p3.add(createPanel(\"1. North\"), \"north\");\n" +
 1055  
                           "p3.add(createPanel(\"2. South\"), \"south\");\n" +
 1056  
                           "p3.add(createPanel(\"3. West\"), \"west\");\n" +
 1057  
                           "p3.add(createPanel(\"4. East\"), \"east\");\n" +
 1058  
                           "p3.add(createButton(\"5. Normal\"));\n" +
 1059  
                           "\n" +
 1060  
                           "JPanel p4 = createTabPanel(new MigLayout());\n" +
 1061  
                           "\n" +
 1062  
                           "p4.add(createPanel(\"1. North\"), \"north\");\n" +
 1063  
                           "p4.add(createPanel(\"2. North\"), \"north\");\n" +
 1064  
                           "p4.add(createPanel(\"3. West\"), \"west\");\n" +
 1065  
                           "p4.add(createPanel(\"4. West\"), \"west\");\n" +
 1066  
                           "p4.add(createPanel(\"5. South\"), \"south\");\n" +
 1067  
                           "p4.add(createPanel(\"6. East\"), \"east\");\n" +
 1068  
                           "p4.add(createButton(\"7. Normal\"));\n" +
 1069  
                           "p4.add(createButton(\"8. Normal\"));\n" +
 1070  
                           "p4.add(createButton(\"9. Normal\"));\n" +
 1071  
                           "\n" +
 1072  
                           "JPanel p5 = createTabPanel(new MigLayout(\"fillx\", \"[c]\", \"\"));\n" +
 1073  
                           "\n" +
 1074  
                           "p5.add(createPanel(\"1. North\"), \"north\");\n" +
 1075  
                           "p5.add(createPanel(\"2. North\"), \"north\");\n" +
 1076  
                           "p5.add(createPanel(\"3. West\"), \"west\");\n" +
 1077  
                           "p5.add(createPanel(\"4. West\"), \"west\");\n" +
 1078  
                           "p5.add(createPanel(\"5. South\"), \"south\");\n" +
 1079  
                           "p5.add(createPanel(\"6. East\"), \"east\");\n" +
 1080  
                           "p5.add(createButton(\"7. Normal\"));\n" +
 1081  
                           "p5.add(createButton(\"8. Normal\"));\n" +
 1082  
                           "p5.add(createButton(\"9. Normal\"));\n" +
 1083  
                           "\n" +
 1084  
                           "JPanel p6 = createTabPanel(new MigLayout(\"fill\", \"\", \"\"));\n" +
 1085  
                           "\n" +
 1086  
                           "Random rand = new Random();\n" +
 1087  
                           "String[] sides = {\"north\", \"east\", \"south\", \"west\"};\n" +
 1088  
                           "for (int i = 0; i < 20; i++) {\n" +
 1089  
                           "\tint side = rand.nextInt(4);\n" +
 1090  
                           "\tp6.add(createPanel((i + 1) + \" \" + sides[side]), sides[side]);\n" +
 1091  
                           "}\n" +
 1092  
                           "p6.add(createButton(\"I'm in the middle!\"), \"grow\");\n" +
 1093  
                           "\n" +
 1094  
                           "tabbedPane.addTab(\"Docking 1 (fill)\", p1);\n" +
 1095  
                           "tabbedPane.addTab(\"Docking 2 (fill)\", p2);\n" +
 1096  
                           "tabbedPane.addTab(\"Docking 3\", p3);\n" +
 1097  
                           "tabbedPane.addTab(\"Docking 4\", p4);\n" +
 1098  
                           "tabbedPane.addTab(\"Docking 5 (fillx)\", p5);\n" +
 1099  
                           "tabbedPane.addTab(\"Docking Spiral\", new JScrollPane(p6));");
 1100  
 
 1101  
                 return tabbedPane;
 1102  
         }
 1103  
 
 1104  
         public JComponent createAbsolute_Position()
 1105  
         {
 1106  
                 JTabbedPane tabbedPane = new JTabbedPane();
 1107  
 
 1108  
                 // Pos tab
 1109  
                 final JPanel posPanel = createTabPanel(new MigLayout());
 1110  
 
 1111  
                 posPanel.add(createButton(), "pos 0.5al 0al");
 1112  
                 posPanel.add(createButton(), "pos 1al 0al");
 1113  
                 posPanel.add(createButton(), "pos 0.5al 0.5al");
 1114  
                 posPanel.add(createButton(), "pos 5in 45lp");
 1115  
                 posPanel.add(createButton(), "pos 0.5al 0.5al");
 1116  
                 posPanel.add(createButton(), "pos 0.5al 1.0al");
 1117  
                 posPanel.add(createButton(), "pos 1al .25al");
 1118  
                 posPanel.add(createButton(), "pos visual.x2-pref visual.y2-pref");
 1119  
                 posPanel.add(createButton(), "pos 1al -1in");
 1120  
                 posPanel.add(createButton(), "pos 100 100");
 1121  
                 posPanel.add(createButton(), "pos (10+(20*3lp)) 200");
 1122  
                 posPanel.add(createButton("Drag Window! (pos 500-container.xpos 500-container.ypos)"),
 1123  
                                             "pos 500-container.xpos 500-container.ypos");
 1124  
 
 1125  
                 // Bounds tab
 1126  
                 JPanel boundsPanel = createTabPanel(new MigLayout());
 1127  
 
 1128  
                 String constr = "pos (visual.x+visual.w*0.1) visual.y2-40 (visual.x2-visual.w*0.1) visual.y2";
 1129  
                 JLabel southLabel = createLabel(constr, SwingConstants.CENTER);
 1130  
                 southLabel.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));
 1131  
                 southLabel.setBackground(new Color(200, 200, 255, benchRuns == 0 ? 70 : 255));
 1132  
                 southLabel.setOpaque(true);
 1133  
                 southLabel.setFont(southLabel.getFont().deriveFont(Font.BOLD));
 1134  
                 boundsPanel.add(southLabel, constr);
 1135  
 
 1136  
                 boundsPanel.add(createButton(), "pos 0 0 container.x2 n");
 1137  
                 boundsPanel.add(createButton(), "pos visual.x 40 visual.x2 70");
 1138  
                 boundsPanel.add(createButton(), "pos visual.x 100 visual.x2 p");
 1139  
                 boundsPanel.add(createButton(), "pos 0.1al 0.4al n (visual.y2 - 10)");
 1140  
                 boundsPanel.add(createButton(), "pos 0.9al 0.4al n visual.y2-10");
 1141  
                 boundsPanel.add(createButton(), "pos 0.5al 0.5al, pad 3 0 -3 0");
 1142  
                 boundsPanel.add(createButton(), "pos n n 50% 50%");
 1143  
                 boundsPanel.add(createButton(), "pos 50% 50% n n");
 1144  
                 boundsPanel.add(createButton(), "pos 50% n n 50%");
 1145  
                 boundsPanel.add(createButton(), "pos n 50% 50% n");
 1146  
 
 1147  
                 tabbedPane.addTab("X Y Positions", posPanel);
 1148  
                 tabbedPane.addTab("X1 Y1 X2 Y2 Bounds", boundsPanel);
 1149  
 
 1150  
                 // Glass pane tab
 1151  
                 if (benchRuns == 0) {
 1152  
                         final JPanel glassPanel = createTabPanel(new MigLayout("align c c, ins 0"));
 1153  
                         final JButton butt = createButton("Press me!!");
 1154  
                         glassPanel.add(butt);
 1155  
 
 1156  
                         butt.addActionListener(new ActionListener()                {
 1157  
                                 public void actionPerformed(ActionEvent e)
 1158  
                                 {
 1159  
                                         butt.setEnabled(false);
 1160  
                                         final JPanel bg = new JPanel(new MigLayout("align c c,fill")) {
 1161  
                                                 public void paint(Graphics g)
 1162  
                                                 {
 1163  
                                                         g.setColor(getBackground());
 1164  
                                                         g.fillRect(0, 0, getWidth(), getHeight());
 1165  
                                                         super.paint(g);
 1166  
                                                 }
 1167  
                                         };
 1168  
                                         bg.setOpaque(OPAQUE);
 1169  
                                         configureActiveComponet(bg);
 1170  
 
 1171  
                                         final JLabel label = createLabel("You don't need a GlassPane to be cool!");
 1172  
                                         label.setFont(label.getFont().deriveFont(30f));
 1173  
                                         label.setForeground(new Color(255, 255, 255, 0));
 1174  
                                         bg.add(label, "align 50% 30%");
 1175  
 
 1176  
                                         glassPanel.add(bg, "pos visual.x visual.y visual.x2 visual.y2", 0);
 1177  
                                         final long startTime = System.nanoTime();
 1178  
                                         final long endTime = startTime + 500000000L;
 1179  
 
 1180  
                                         glassPanel.revalidate();
 1181  
 
 1182  
                                         final javax.swing.Timer timer = new Timer(25, null);
 1183  
 
 1184  
                                         timer.addActionListener(new ActionListener() {
 1185  
                                                 public void actionPerformed(ActionEvent e)
 1186  
                                                 {
 1187  
                                                         long now = System.nanoTime();
 1188  
                                                         int alpha = (int) (((now - startTime) / (double) (endTime - startTime)) * 300);
 1189  
                                                         if (alpha < 150)
 1190  
                                                                 bg.setBackground(new Color(100, 100, 100, alpha));
 1191  
 
 1192  
                                                         if (alpha > 150 && alpha < 405) {
 1193  
                                                                 label.setForeground(new Color(255, 255, 255, (alpha - 150)));
 1194  
                                                                 bg.repaint();
 1195  
                                                         }
 1196  
                                                         if (alpha > 405)
 1197  
                                                                 timer.stop();
 1198  
                                                 }
 1199  
                                         });
 1200  
                                         timer.start();
 1201  
                                 }
 1202  
                         });
 1203  
                         tabbedPane.addTab("GlassPane Substitute", glassPanel);
 1204  
                         addComponentListener(new ComponentAdapter() {
 1205  
                                 public void componentMoved(ComponentEvent e) {
 1206  
                                         if (posPanel.isDisplayable()) {
 1207  
                                                 posPanel.revalidate();
 1208  
                                         } else {
 1209  
                                                 removeComponentListener(this);
 1210  
                                         }
 1211  
                                 }
 1212  
                         });
 1213  
                 }
 1214  
 
 1215  
                 // Disregard. Just forgetting the source code text close to the source code.
 1216  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 1217  
                           "\n" +
 1218  
                           "// Pos tab\n" +
 1219  
                           "final JPanel posPanel = createTabPanel(new MigLayout());\n" +
 1220  
                           "\n" +
 1221  
                           "posPanel.add(createButton(), \"pos 0.5al 0al\");\n" +
 1222  
                           "posPanel.add(createButton(), \"pos 1al 0al\");\n" +
 1223  
                           "posPanel.add(createButton(), \"pos 0.5al 0.5al\");\n" +
 1224  
                           "posPanel.add(createButton(), \"pos 5in 45lp\");\n" +
 1225  
                           "posPanel.add(createButton(), \"pos 0.5al 0.5al\");\n" +
 1226  
                           "posPanel.add(createButton(), \"pos 0.5al 1.0al\");\n" +
 1227  
                           "posPanel.add(createButton(), \"pos 1al .25al\");\n" +
 1228  
                           "posPanel.add(createButton(), \"pos visual.x2-pref visual.y2-pref\");\n" +
 1229  
                           "posPanel.add(createButton(), \"pos 1al -1in\");\n" +
 1230  
                           "posPanel.add(createButton(), \"pos 100 100\");\n" +
 1231  
                           "posPanel.add(createButton(), \"pos (10+(20*3lp)) 200\");\n" +
 1232  
                           "posPanel.add(createButton(\"Drag Window! (pos 500-container.xpos 500-container.ypos)\"),\n" +
 1233  
                           "                            \"pos 500-container.xpos 500-container.ypos\");\n" +
 1234  
                           "\n" +
 1235  
                           "// Bounds tab\n" +
 1236  
                           "JPanel boundsPanel = createTabPanel(new MigLayout());\n" +
 1237  
                           "\n" +
 1238  
                           "String constr = \"pos (visual.x+visual.w*0.1) visual.y2-40 (visual.x2-visual.w*0.1) visual.y2\";\n" +
 1239  
                           "JLabel southLabel = createLabel(constr, SwingConstants.CENTER);\n" +
 1240  
                           "southLabel.setBorder(new LineBorder(Color.LIGHT_GRAY, 1));\n" +
 1241  
                           "southLabel.setBackground(new Color(200, 200, 255, 70));\n" +
 1242  
                           "southLabel.setOpaque(true);\n" +
 1243  
                           "southLabel.setFont(southLabel.getFont().deriveFont(Font.BOLD));\n" +
 1244  
                           "boundsPanel.add(southLabel, constr);\n" +
 1245  
                           "\n" +
 1246  
                           "boundsPanel.add(createButton(), \"pos 0 0 container.x2 n\");\n" +
 1247  
                           "boundsPanel.add(createButton(), \"pos visual.x 40 visual.x2 70\");\n" +
 1248  
                           "boundsPanel.add(createButton(), \"pos visual.x 100 visual.x2 p\");\n" +
 1249  
                           "boundsPanel.add(createButton(), \"pos 0.1al 0.4al n visual.y2-10\");\n" +
 1250  
                           "boundsPanel.add(createButton(), \"pos 0.9al 0.4al n visual.y2-10\");\n" +
 1251  
                           "boundsPanel.add(createButton(), \"pos 0.5al 0.5al, pad 3 0 -3 0\");\n" +
 1252  
                           "boundsPanel.add(createButton(), \"pos n n 50% 50%\");\n" +
 1253  
                           "boundsPanel.add(createButton(), \"pos 50% 50% n n\");\n" +
 1254  
                           "boundsPanel.add(createButton(), \"pos 50% n n 50%\");\n" +
 1255  
                           "boundsPanel.add(createButton(), \"pos n 50% 50% n\");\n" +
 1256  
                           "\n" +
 1257  
                           "// Glass pane tab\n" +
 1258  
                           "final JPanel glassPanel = createTabPanel(new MigLayout(\"align c c, ins 0\"));\n" +
 1259  
                           "final JButton butt = createButton(\"Press me!!\");\n" +
 1260  
                           "glassPanel.add(butt);\n" +
 1261  
                           "\n" +
 1262  
                           "butt.addActionListener(new ActionListener()\t\t{\n" +
 1263  
                           "\tpublic void actionPerformed(ActionEvent e)\n" +
 1264  
                           "\t{\n" +
 1265  
                           "\t\tbutt.setEnabled(false);\n" +
 1266  
                           "\t\tfinal JPanel bg = new JPanel(new MigLayout(\"align c c,fill\")) {\n" +
 1267  
                           "\t\t\tpublic void paint(Graphics g)\n" +
 1268  
                           "\t\t\t{\n" +
 1269  
                           "\t\t\t\tg.setColor(getBackground());\n" +
 1270  
                           "\t\t\t\tg.fillRect(0, 0, getWidth(), getHeight());\n" +
 1271  
                           "\t\t\t\tsuper.paint(g);\n" +
 1272  
                           "\t\t\t}\n" +
 1273  
                           "\t\t};\n" +
 1274  
                           "\t\tbg.setOpaque(OPAQUE);\n" +
 1275  
                           "\t\tconfigureActiveComponet(bg);\n" +
 1276  
                           "\n" +
 1277  
                           "\t\tfinal JLabel label = createLabel(\"You don't need a GlassPane to be cool!\");\n" +
 1278  
                           "\t\tlabel.setFont(label.getFont().deriveFont(30f));\n" +
 1279  
                           "\t\tlabel.setForeground(new Color(255, 255, 255, 0));\n" +
 1280  
                           "\t\tbg.add(label, \"align 50% 30%\");\n" +
 1281  
                           "\n" +
 1282  
                           "\t\tglassPanel.add(bg, \"pos visual.x visual.y visual.x2 visual.y2\", 0);\n" +
 1283  
                           "\t\tfinal long startTime = System.nanoTime();\n" +
 1284  
                           "\t\tfinal long endTime = startTime + 500000000L;\n" +
 1285  
                           "\n" +
 1286  
                           "\t\tglassPanel.revalidate();\n" +
 1287  
                           "\n" +
 1288  
                           "\t\tfinal javax.swing.Timer timer = new Timer(25, null);\n" +
 1289  
                           "\n" +
 1290  
                           "\t\ttimer.addActionListener(new ActionListener() {\n" +
 1291  
                           "\t\t\tpublic void actionPerformed(ActionEvent e)\n" +
 1292  
                           "\t\t\t{\n" +
 1293  
                           "\t\t\t\tlong now = System.nanoTime();\n" +
 1294  
                           "\t\t\t\tint alpha = (int) (((now - startTime) / (double) (endTime - startTime)) * 300);\n" +
 1295  
                           "\t\t\t\tif (alpha < 150)\n" +
 1296  
                           "\t\t\t\t\tbg.setBackground(new Color(100, 100, 100, alpha));\n" +
 1297  
                           "\n" +
 1298  
                           "\t\t\t\tif (alpha > 150 && alpha < 405) {\n" +
 1299  
                           "\t\t\t\t\tlabel.setForeground(new Color(255, 255, 255, (alpha - 150)));\n" +
 1300  
                           "\t\t\t\t\tbg.repaint();\n" +
 1301  
                           "\t\t\t\t}\n" +
 1302  
                           "\t\t\t\tif (alpha > 405)\n" +
 1303  
                           "\t\t\t\t\ttimer.stop();\n" +
 1304  
                           "\t\t\t}\n" +
 1305  
                           "\t\t});\n" +
 1306  
                           "\t\ttimer.start();\n" +
 1307  
                           "\t}\n" +
 1308  
                           "});\n" +
 1309  
                           "\n" +
 1310  
                           "tabbedPane.addTab(\"X Y Positions\", posPanel);\n" +
 1311  
                           "tabbedPane.addTab(\"X1 Y1 X2 Y2 Bounds\", boundsPanel);\n" +
 1312  
                           "tabbedPane.addTab(\"GlassPane Substitute\", glassPanel);\n" +
 1313  
                           "\n" +
 1314  
                           "addComponentListener(new ComponentAdapter() {\n" +
 1315  
                           "\tpublic void componentMoved(ComponentEvent e) {\n" +
 1316  
                           "\t\tif (posPanel.isDisplayable()) {\n" +
 1317  
                           "\t\t\tposPanel.revalidate();\n" +
 1318  
                           "\t\t} else {\n" +
 1319  
                           "\t\t\tremoveComponentListener(this);\n" +
 1320  
                           "\t\t}\n" +
 1321  
                           "\t}\n" +
 1322  
                           "});");
 1323  
 
 1324  
                 return tabbedPane;
 1325  
         }
 1326  
 
 1327  
         public JComponent createComponent_Links()
 1328  
         {
 1329  
                 JTabbedPane tabbedPane = new JTabbedPane();
 1330  
 
 1331  
                 JPanel linksPanel = createTabPanel(new MigLayout());
 1332  
 
 1333  
                 // Links tab
 1334  
                 JButton mini = createButton("Mini");
 1335  
                 mini.setMargin(new Insets(0, 1, 0, 1));
 1336  
                 linksPanel.add(mini, "pos null ta.y ta.x2 null");
 1337  
                 linksPanel.add(createTextArea("Components, Please Link to Me!\nMy ID is: 'ta'", 3, 30), "id ta, pos 0.5al 0.5al");
 1338  
                 linksPanel.add(createButton(), "id b1,pos ta.x2 ta.y2");
 1339  
                 linksPanel.add(createButton(), "pos b1.x2+rel b1.y visual.x2 null");
 1340  
                 linksPanel.add(createButton(), "pos ta.x2+rel ta.y visual.x2 null");
 1341  
                 linksPanel.add(createButton(), "pos null ta.y+(ta.h-pref)/2 ta.x-rel null");
 1342  
                 linksPanel.add(createButton(), "pos ta.x ta.y2+100 ta.x2 null");
 1343  
                 linksPanel.add(createCheck("pos (ta.x+indent) (ta.y2+rel)"),
 1344  
                                            "pos (ta.x+indent) (ta.y2+rel)");
 1345  
 
 1346  
                 // External tab
 1347  
                 JPanel externalPanel = createTabPanel(new MigLayout());
 1348  
 
 1349  
                 JButton extButt = createButton("Bounds Externally Set!");
 1350  
                 extButt.setBounds(250, 130, 200, 40);
 1351  
                 externalPanel.add(extButt, "id ext, external");
 1352  
                 externalPanel.add(createButton(), "pos ext.x2 ext.y2");
 1353  
                 externalPanel.add(createButton(), "pos null null ext.x ext.y");
 1354  
 
 1355  
                 // Start/End Group tab
 1356  
                 JPanel egPanel = createTabPanel(new MigLayout());
 1357  
 
 1358  
                 egPanel.add(createButton(), "id b1, endgroupx g1, pos 200 200");
 1359  
                 egPanel.add(createButton(), "id b2, endgroupx g1, pos (b1.x+2ind) (b1.y2+rel)");
 1360  
                 egPanel.add(createButton(), "id b3, endgroupx g1, pos (b1.x+4ind) (b2.y2+rel)");
 1361  
                 egPanel.add(createButton(), "id b4, endgroupx g1, pos (b1.x+6ind) (b3.y2+rel)");
 1362  
 
 1363  
                 // Group Bounds tab
 1364  
                 JPanel gpPanel = createTabPanel(new MigLayout());
 1365  
 
 1366  
                 gpPanel.add(createButton(), "id grp1.b1, pos n 0.5al 50% n");
 1367  
                 gpPanel.add(createButton(), "id grp1.b2, pos 50% 0.5al n n");
 1368  
                 gpPanel.add(createButton(), "id grp1.b3, pos 0.5al n n b1.y");
 1369  
                 gpPanel.add(createButton(), "id grp1.b4, pos 0.5al b1.y2 n n");
 1370  
 
 1371  
                 gpPanel.add(createButton(), "pos n grp1.y2 grp1.x n");
 1372  
                 gpPanel.add(createButton(), "pos n n grp1.x grp1.y");
 1373  
                 gpPanel.add(createButton(), "pos grp1.x2 n n grp1.y");
 1374  
                 gpPanel.add(createButton(), "pos grp1.x2 grp1.y2");
 1375  
 
 1376  
                 JPanel boundsPanel = new JPanel(null);
 1377  
                 boundsPanel.setBackground(new Color(200, 200, 255));
 1378  
                 gpPanel.add(boundsPanel, "pos grp1.x grp1.y grp1.x2 grp1.y2");
 1379  
 
 1380  
 
 1381  
                 tabbedPane.addTab("Component Links", linksPanel);
 1382  
                 tabbedPane.addTab("External Components", externalPanel);
 1383  
                 tabbedPane.addTab("End Grouping", egPanel);
 1384  
                 tabbedPane.addTab("Group Bounds", gpPanel);
 1385  
 
 1386  
                 // Disregard. Just forgetting the source code text close to the source code.
 1387  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 1388  
                           "\n" +
 1389  
                           "JPanel linksPanel = createTabPanel(new MigLayout());\n" +
 1390  
                           "\n" +
 1391  
                           "// Links tab\n" +
 1392  
                           "JButton mini = createButton(\"Mini\");\n" +
 1393  
                           "mini.setMargin(new Insets(0, 1, 0, 1));\n" +
 1394  
                           "linksPanel.add(mini, \"pos null ta.y ta.x2 null\");\n" +
 1395  
                           "linksPanel.add(createTextArea(\"Components, Please Link to Me!\\nMy ID is: 'ta'\", 3, 30), \"id ta, pos 0.5al 0.5al\");\n" +
 1396  
                           "linksPanel.add(createButton(), \"id b1,pos ta.x2 ta.y2\");\n" +
 1397  
                           "linksPanel.add(createButton(), \"pos b1.x2+rel b1.y visual.x2 null\");\n" +
 1398  
                           "linksPanel.add(createButton(), \"pos ta.x2+rel ta.y visual.x2 null\");\n" +
 1399  
                           "linksPanel.add(createButton(), \"pos null ta.y+(ta.h-pref)/2 ta.x-rel null\");\n" +
 1400  
                           "linksPanel.add(createButton(), \"pos ta.x ta.y2+100 ta.x2 null\");\n" +
 1401  
                           "linksPanel.add(createCheck(\"pos (ta.x+indent) (ta.y2+rel)\"),\n" +
 1402  
                           "                           \"pos (ta.x+indent) (ta.y2+rel)\");\n" +
 1403  
                           "\n" +
 1404  
                           "// External tab\n" +
 1405  
                           "JPanel externalPanel = createTabPanel(new MigLayout());\n" +
 1406  
                           "\n" +
 1407  
                           "JButton extButt = createButton(\"Bounds Externally Set!\");\n" +
 1408  
                           "extButt.setBounds(250, 130, 200, 40);\n" +
 1409  
                           "externalPanel.add(extButt, \"id ext, external\");\n" +
 1410  
                           "externalPanel.add(createButton(), \"pos ext.x2 ext.y2\");\n" +
 1411  
                           "externalPanel.add(createButton(), \"pos null null ext.x ext.y\");\n" +
 1412  
                           "\n" +
 1413  
                           "// Start/End Group tab\n" +
 1414  
                           "JPanel egPanel = createTabPanel(new MigLayout());\n" +
 1415  
                           "\n" +
 1416  
                           "egPanel.add(createButton(), \"id b1, endgroupx g1, pos 200 200\");\n" +
 1417  
                           "egPanel.add(createButton(), \"id b2, endgroupx g1, pos (b1.x+2ind) (b1.y2+rel)\");\n" +
 1418  
                           "egPanel.add(createButton(), \"id b3, endgroupx g1, pos (b1.x+4ind) (b2.y2+rel)\");\n" +
 1419  
                           "egPanel.add(createButton(), \"id b4, endgroupx g1, pos (b1.x+6ind) (b3.y2+rel)\");\n" +
 1420  
                           "\n" +
 1421  
                           "// Group Bounds tab\n" +
 1422  
                           "JPanel gpPanel = createTabPanel(new MigLayout());\n" +
 1423  
                           "\n" +
 1424  
                           "gpPanel.add(createButton(), \"id grp1.b1, pos n 0.5al 50% n\");\n" +
 1425  
                           "gpPanel.add(createButton(), \"id grp1.b2, pos 50% 0.5al n n\");\n" +
 1426  
                           "gpPanel.add(createButton(), \"id grp1.b3, pos 0.5al n n b1.y\");\n" +
 1427  
                           "gpPanel.add(createButton(), \"id grp1.b4, pos 0.5al b1.y2 n n\");\n" +
 1428  
                           "\n" +
 1429  
                           "gpPanel.add(createButton(), \"pos n grp1.y2 grp1.x n\");\n" +
 1430  
                           "gpPanel.add(createButton(), \"pos n n grp1.x grp1.y\");\n" +
 1431  
                           "gpPanel.add(createButton(), \"pos grp1.x2 n n grp1.y\");\n" +
 1432  
                           "gpPanel.add(createButton(), \"pos grp1.x2 grp1.y2\");\n" +
 1433  
                           "\n" +
 1434  
                           "JPanel boundsPanel = new JPanel(null);\n" +
 1435  
                           "boundsPanel.setBackground(new Color(200, 200, 255));\n" +
 1436  
                           "gpPanel.add(boundsPanel, \"pos grp1.x grp1.y grp1.x2 grp1.y2\");\n" +
 1437  
                           "\n" +
 1438  
                           "\n" +
 1439  
                           "tabbedPane.addTab(\"Component Links\", linksPanel);\n" +
 1440  
                           "tabbedPane.addTab(\"External Components\", externalPanel);\n" +
 1441  
                           "tabbedPane.addTab(\"End Grouping\", egPanel);\n" +
 1442  
                           "tabbedPane.addTab(\"Group Bounds\", gpPanel);");
 1443  
 
 1444  
                 return tabbedPane;
 1445  
         }
 1446  
 
 1447  
         public JComponent createFlow_Direction()
 1448  
         {
 1449  
                 JTabbedPane tabbedPane = new JTabbedPane();
 1450  
 
 1451  
                 tabbedPane.addTab("Layout: flowx, Cell: flowx", createFlowPanel("", "flowx"));
 1452  
                 tabbedPane.addTab("Layout: flowx, Cell: flowy", createFlowPanel("", "flowy"));
 1453  
                 tabbedPane.addTab("Layout: flowy, Cell: flowx", createFlowPanel("flowy", "flowx"));
 1454  
                 tabbedPane.addTab("Layout: flowy, Cell: flowy", createFlowPanel("flowy", "flowy"));
 1455  
 
 1456  
                 // Disregard. Just forgetting the source code text close to the source code.
 1457  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 1458  
                           "\n" +
 1459  
                           "tabbedPane.addTab(\"Layout: flowx, Cell: flowx\", createFlowPanel(\"\", \"flowx\"));\n" +
 1460  
                           "tabbedPane.addTab(\"Layout: flowx, Cell: flowy\", createFlowPanel(\"\", \"flowy\"));\n" +
 1461  
                           "tabbedPane.addTab(\"Layout: flowy, Cell: flowx\", createFlowPanel(\"flowy\", \"flowx\"));\n" +
 1462  
                           "tabbedPane.addTab(\"Layout: flowy, Cell: flowy\", createFlowPanel(\"flowy\", \"flowy\"));" +
 1463  
                                   "\n\tpublic JPanel createFlowPanel(String gridFlow, String cellFlow)\n" +
 1464  
                                   "\t{\n" +
 1465  
                                   "MigLayout lm = new MigLayout(\"center, wrap 3,\" + gridFlow,\n" +
 1466  
                                   "                             \"[110,fill]\",\n" +
 1467  
                                   "                             \"[110,fill]\");\n" +
 1468  
                                   "JPanel panel = createTabPanel(lm);\n" +
 1469  
                                   "\n" +
 1470  
                                   "for (int i = 0; i < 9; i++) {\n" +
 1471  
                                   "\tJButton b = createButton(\"\" + (i + 1));\n" +
 1472  
                                   "\tb.setFont(b.getFont().deriveFont(20f));\n" +
 1473  
                                   "\tpanel.add(b, cellFlow);\n" +
 1474  
                                   "}\n" +
 1475  
                                   "\n" +
 1476  
                                   "JButton b = createButton(\"5:2\");\n" +
 1477  
                                   "b.setFont(b.getFont().deriveFont(20f));\n" +
 1478  
                                   "panel.add(b, cellFlow + \",cell 1 1\");\n" +
 1479  
                                   "\n" +
 1480  
                                   "return panel;\n" +
 1481  
                                   "\t}");
 1482  
 
 1483  
                 return tabbedPane;
 1484  
         }
 1485  
 
 1486  
         public JPanel createFlowPanel(String gridFlow, String cellFlow)
 1487  
         {
 1488  
                 MigLayout lm = new MigLayout("center, wrap 3," + gridFlow,
 1489  
                                              "[110,fill]",
 1490  
                                              "[110,fill]");
 1491  
                 JPanel panel = createTabPanel(lm);
 1492  
 
 1493  
                 Font f = panel.getFont().deriveFont(20f);
 1494  
                 for (int i = 0; i < 9; i++) {
 1495  
                         JComponent b = createPanel("" + (i + 1));
 1496  
                         b.setFont(f);
 1497  
                         panel.add(b, cellFlow);
 1498  
                 }
 1499  
 
 1500  
                 JComponent b = createPanel("5:2");
 1501  
                 b.setFont(f);
 1502  
                 panel.add(b, cellFlow + ",cell 1 1");
 1503  
 
 1504  
                 return panel;
 1505  
         }
 1506  
 
 1507  
         public JComponent createDebug()
 1508  
         {
 1509  
                 return createPlainImpl(true);
 1510  
         }
 1511  
 
 1512  
         public JComponent createButton_Bars()
 1513  
         {
 1514  
                 MigLayout lm = new MigLayout("ins 0 0 15lp 0",
 1515  
                                                   "[grow]",
 1516  
                                                   "[grow][baseline,nogrid]");
 1517  
 
 1518  
                 final JPanel mainPanel = new JPanel(lm);
 1519  
                 final JLabel formatLabel = createLabel("");
 1520  
                 formatLabel.setFont(formatLabel.getFont().deriveFont(Font.BOLD));
 1521  
                 JTabbedPane tabbedPane = new JTabbedPane();
 1522  
 
 1523  
                 JToggleButton winButt = createToggleButton("Windows");
 1524  
                 JToggleButton macButt = createToggleButton("Mac OS X");
 1525  
                 JButton helpButt = createButton("Help");
 1526  
 
 1527  
                 if (benchRuns == 0) {
 1528  
                         winButt.addActionListener(new ActionListener() {
 1529  
                                 public void actionPerformed(ActionEvent e) {
 1530  
                                         PlatformDefaults.setPlatform(PlatformDefaults.WINDOWS_XP);
 1531  
                                         formatLabel.setText("'" + PlatformDefaults.getButtonOrder() + "'");
 1532  
                                         ((JPanel) ((JFrame) Frame.getFrames()[0]).getContentPane()).revalidate();
 1533  
                                 }
 1534  
                         });
 1535  
 
 1536  
                         macButt.addActionListener(new ActionListener() {
 1537  
                                 public void actionPerformed(ActionEvent e) {
 1538  
                                         PlatformDefaults.setPlatform(PlatformDefaults.MAC_OSX);
 1539  
                                         formatLabel.setText(PlatformDefaults.getButtonOrder());
 1540  
                                         ((JPanel) ((JFrame) Frame.getFrames()[0]).getContentPane()).revalidate();
 1541  
                                 }
 1542  
                         });
 1543  
 
 1544  
                         helpButt.addActionListener(new ActionListener() {
 1545  
                                 public void actionPerformed(ActionEvent e) {
 1546  
                                         JOptionPane.showMessageDialog(mainPanel, "See JavaDoc for PlatformConverter.getButtonBarOrder(..) for details on the format string.");
 1547  
                                 }
 1548  
                         });
 1549  
                 }
 1550  
 
 1551  
                 ButtonGroup bg = new ButtonGroup();
 1552  
                 bg.add(winButt);
 1553  
                 bg.add(macButt);
 1554  
                 if (benchRuns == 0) {
 1555  
                         if (PlatformDefaults.getCurrentPlatform() == PlatformDefaults.MAC_OSX) {
 1556  
                                 macButt.doClick();
 1557  
                         } else {
 1558  
                                 winButt.doClick();
 1559  
                         }
 1560  
                 }
 1561  
 
 1562  
                 tabbedPane.addTab("Buttons", createButtonBarsPanel("help", false));
 1563  
                 tabbedPane.addTab("Buttons with Help2", createButtonBarsPanel("help2", false));
 1564  
                 tabbedPane.addTab("Buttons (Same width)", createButtonBarsPanel("help", true));
 1565  
 
 1566  
                 mainPanel.add(tabbedPane, "grow,wrap");
 1567  
 
 1568  
                 mainPanel.add(createLabel("Button Order:"));
 1569  
                 mainPanel.add(formatLabel, "growx");
 1570  
                 mainPanel.add(winButt);
 1571  
                 mainPanel.add(macButt);
 1572  
                 mainPanel.add(helpButt, "gapbefore unrel");
 1573  
 
 1574  
                 // Disregard. Just forgetting the source code text close to the source code.
 1575  
                 setSource("MigLayout lm = new MigLayout(\"ins 0 0 15lp 0\",\n" +
 1576  
                           "                                  \"[grow]\",\n" +
 1577  
                           "                                  \"[grow][baseline,nogrid,gap unrelated]\");\n" +
 1578  
                           "\n" +
 1579  
                           "final JPanel mainPanel = new JPanel(lm);\n" +
 1580  
                           "final JLabel formatLabel = createLabel(\"\");\n" +
 1581  
                           "formatLabel.setFont(formatLabel.getFont().deriveFont(Font.BOLD));\n" +
 1582  
                           "JTabbedPane tabbedPane = new JTabbedPane();\n" +
 1583  
                           "\n" +
 1584  
                           "JToggleButton winButt = createToggleButton(\"Windows\");\n" +
 1585  
                           "\n" +
 1586  
                           "winButt.addActionListener(new ActionListener() {\n" +
 1587  
                           "\tpublic void actionPerformed(ActionEvent e) {\n" +
 1588  
                           "\t\tPlatformDefaults.setPlatform(PlatformDefaults.WINDOWS_XP);\n" +
 1589  
                           "\t\tformatLabel.setText(\"'\" + PlatformDefaults.getButtonOrder() + \"'\");\n" +
 1590  
                           "\t\tSwingUtilities.updateComponentTreeUI(mainPanel);\n" +
 1591  
                           "\t}\n" +
 1592  
                           "});\n" +
 1593  
                           "\n" +
 1594  
                           "JToggleButton macButt = createToggleButton(\"Mac OS X\");\n" +
 1595  
                           "macButt.addActionListener(new ActionListener() {\n" +
 1596  
                           "\tpublic void actionPerformed(ActionEvent e) {\n" +
 1597  
                           "\t\tPlatformDefaults.setPlatform(PlatformDefaults.MAC_OSX);\n" +
 1598  
                           "\t\tformatLabel.setText(PlatformDefaults.getButtonOrder());\n" +
 1599  
                           "\t\tSwingUtilities.updateComponentTreeUI(mainPanel);\n" +
 1600  
                           "\t}\n" +
 1601  
                           "});\n" +
 1602  
                           "\n" +
 1603  
                           "JButton helpButt = createButton(\"Help\");\n" +
 1604  
                           "helpButt.addActionListener(new ActionListener() {\n" +
 1605  
                           "\tpublic void actionPerformed(ActionEvent e) {\n" +
 1606  
                           "\t\tJOptionPane.showMessageDialog(mainPanel, \"See JavaDoc for PlatformConverter.getButtonBarOrder(..) for details on the format string.\");\n" +
 1607  
                           "\t}\n" +
 1608  
                           "});\n" +
 1609  
                           "\n" +
 1610  
                           "ButtonGroup bg = new ButtonGroup();\n" +
 1611  
                           "bg.add(winButt);\n" +
 1612  
                           "bg.add(macButt);\n" +
 1613  
                           "winButt.doClick();\n" +
 1614  
                           "\n" +
 1615  
                           "tabbedPane.addTab(\"Buttons\", createButtonBarsPanel(\"help\", false));\n" +
 1616  
                           "tabbedPane.addTab(\"Buttons with Help2\", createButtonBarsPanel(\"help2\", false));\n" +
 1617  
                           "tabbedPane.addTab(\"Buttons (Same width)\", createButtonBarsPanel(\"help\", true));\n" +
 1618  
                           "\n" +
 1619  
                           "mainPanel.add(tabbedPane, \"grow,wrap\");\n" +
 1620  
                           "\n" +
 1621  
                           "mainPanel.add(createLabel(\"Button Order:\"));\n" +
 1622  
                           "mainPanel.add(formatLabel, \"growx\");\n" +
 1623  
                           "mainPanel.add(winButt);\n" +
 1624  
                           "mainPanel.add(macButt);\n" +
 1625  
                           "mainPanel.add(helpButt, \"gapbefore unrel\");");
 1626  
 
 1627  
                 return mainPanel;
 1628  
         }
 1629  
 
 1630  
         private JComponent createButtonBarsPanel(String helpTag, boolean sizeLocked)
 1631  
         {
 1632  
                 MigLayout lm = new MigLayout("nogrid, fillx, aligny 100%, gapy unrel");
 1633  
                 JPanel panel = createTabPanel(lm);
 1634  
 
 1635  
                 // Notice that the order in the rows below does not matter...
 1636  
                 String[][] buttons = new String[][] {
 1637  
                                 {"OK"},
 1638  
                                 {"No", "Yes"},
 1639  
                                 {"Help", "Close"},
 1640  
                                 {"OK", "Help"},
 1641  
                                 {"OK", "Cancel", "Help"},
 1642  
                                 {"OK", "Cancel", "Apply", "Help"},
 1643  
                                 {"No", "Yes", "Cancel"},
 1644  
                                 {"Help", "< Back", "Forward >", "Cancel"},
 1645  
                                 {"Print...", "Cancel", "Help"}
 1646  
                 };
 1647  
 
 1648  
                 for (int r = 0; r < buttons.length; r++) {
 1649  
                         for (int i = 0; i < buttons[r].length; i++) {
 1650  
                                 String txt = buttons[r][i];
 1651  
                                 String tag = txt;
 1652  
 
 1653  
                                 if (txt.equals("Help")) {
 1654  
                                         tag = helpTag;
 1655  
                                 } else if (txt.equals("< Back")) {
 1656  
                                         tag = "back";
 1657  
                                 } else if (txt.equals("Close")) {
 1658  
                                         tag = "cancel";
 1659  
                                 } else if (txt.equals("Forward >")) {
 1660  
                                         tag = "next";
 1661  
                                 } else if (txt.equals("Print...")) {
 1662  
                                         tag = "other";
 1663  
                                 }
 1664  
                                 String wrap = (i == buttons[r].length - 1) ? ",wrap" : "";
 1665  
                                 String sizeGroup = sizeLocked ? ("sgx " + r + ",") : "";
 1666  
                                 panel.add(createButton(txt), sizeGroup + "tag " + tag + wrap);
 1667  
                         }
 1668  
                 }
 1669  
                 return panel;
 1670  
         }
 1671  
 
 1672  
         public JComponent createOrientation()
 1673  
         {
 1674  
                 JTabbedPane tabbedPane = new JTabbedPane();
 1675  
 
 1676  
                 MigLayout lm = new MigLayout("flowy", "[grow,fill]", "[]20[]20[]20[]");
 1677  
                 JPanel mainPanel = createTabPanel(lm);
 1678  
 
 1679  
                 // Default orientation
 1680  
                 MigLayout defLM = new MigLayout("", "[trailing][grow,fill]", "");
 1681  
 
 1682  
                 JPanel defPanel = createTabPanel(defLM);
 1683  
                 addSeparator(defPanel, "Default Orientation");
 1684  
                 defPanel.add(createLabel("Level of Trust"));
 1685  
                 defPanel.add(createTextField(""), "span,growx");
 1686  
                 defPanel.add(createLabel("Radar Presentation"));
 1687  
                 defPanel.add(createTextField(""));
 1688  
                 defPanel.add(createTextField(""));
 1689  
 
 1690  
                 // Right-to-left, Top-to-bottom
 1691  
                 MigLayout rtlLM = new MigLayout("rtl,ttb",
 1692  
                                                 "[trailing][grow,fill]",
 1693  
                                                 "");
 1694  
                 JPanel rtlPanel = createTabPanel(rtlLM);
 1695  
                 addSeparator(rtlPanel, "Right to Left");
 1696  
                 rtlPanel.add(createLabel("Level of Trust"));
 1697  
                 rtlPanel.add(createTextField(""), "span,growx");
 1698  
                 rtlPanel.add(createLabel("Radar Presentation"));
 1699  
                 rtlPanel.add(createTextField(""));
 1700  
                 rtlPanel.add(createTextField(""));
 1701  
 
 1702  
                 // Right-to-left, Bottom-to-top
 1703  
                 MigLayout rtlbLM = new MigLayout("rtl,btt",
 1704  
                                                       "[trailing][grow,fill]",
 1705  
                                                       "");
 1706  
                 JPanel rtlbPanel = createTabPanel(rtlbLM);
 1707  
                 addSeparator(rtlbPanel, "Right to Left, Bottom to Top");
 1708  
                 rtlbPanel.add(createLabel("Level of Trust"));
 1709  
                 rtlbPanel.add(createTextField(""), "span,growx");
 1710  
                 rtlbPanel.add(createLabel("Radar Presentation"));
 1711  
                 rtlbPanel.add(createTextField(""));
 1712  
                 rtlbPanel.add(createTextField(""));
 1713  
 
 1714  
                 // Left-to-right, Bottom-to-top
 1715  
                 MigLayout ltrbLM = new MigLayout("ltr,btt",
 1716  
                                                       "[trailing][grow,fill]",
 1717  
                                                       "");
 1718  
                 JPanel ltrbPanel = createTabPanel(ltrbLM);
 1719  
                 addSeparator(ltrbPanel, "Left to Right, Bottom to Top");
 1720  
                 ltrbPanel.add(createLabel("Level of Trust"));
 1721  
                 ltrbPanel.add(createTextField(""), "span,growx");
 1722  
                 ltrbPanel.add(createLabel("Radar Presentation"));
 1723  
                 ltrbPanel.add(createTextField(""));
 1724  
                 ltrbPanel.add(createTextField(""));
 1725  
 
 1726  
                 mainPanel.add(defPanel);
 1727  
                 mainPanel.add(rtlPanel);
 1728  
                 mainPanel.add(rtlbPanel);
 1729  
                 mainPanel.add(ltrbPanel);
 1730  
 
 1731  
                 tabbedPane.addTab("Orientation", mainPanel);
 1732  
 
 1733  
                 // Disregard. Just forgetting the source code text close to the source code.
 1734  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 1735  
                           "\n" +
 1736  
                           "MigLayout lm = new MigLayout(\"flowy\", \"[grow,fill]\", \"[]0[]15lp[]0[]\");\n" +
 1737  
                           "JPanel mainPanel = createTabPanel(lm);\n" +
 1738  
                           "\n" +
 1739  
                           "// Default orientation\n" +
 1740  
                           "MigLayout defLM = new MigLayout(\"\", \"[][grow,fill]\", \"\");\n" +
 1741  
                           "\n" +
 1742  
                           "JPanel defPanel = createTabPanel(defLM);\n" +
 1743  
                           "addSeparator(defPanel, \"Default Orientation\");\n" +
 1744  
                           "defPanel.add(createLabel(\"Level\"));\n" +
 1745  
                           "defPanel.add(createTextField(\"\"), \"span,growx\");\n" +
 1746  
                           "defPanel.add(createLabel(\"Radar\"));\n" +
 1747  
                           "defPanel.add(createTextField(\"\"));\n" +
 1748  
                           "defPanel.add(createTextField(\"\"));\n" +
 1749  
                           "\n" +
 1750  
                           "// Right-to-left, Top-to-bottom\n" +
 1751  
                           "MigLayout rtlLM = new MigLayout(\"rtl,ttb\",\n" +
 1752  
                           "                                \"[][grow,fill]\",\n" +
 1753  
                           "                                \"\");\n" +
 1754  
                           "JPanel rtlPanel = createTabPanel(rtlLM);\n" +
 1755  
                           "addSeparator(rtlPanel, \"Right to Left\");\n" +
 1756  
                           "rtlPanel.add(createLabel(\"Level\"));\n" +
 1757  
                           "rtlPanel.add(createTextField(\"\"), \"span,growx\");\n" +
 1758  
                           "rtlPanel.add(createLabel(\"Radar\"));\n" +
 1759  
                           "rtlPanel.add(createTextField(\"\"));\n" +
 1760  
                           "rtlPanel.add(createTextField(\"\"));\n" +
 1761  
                           "\n" +
 1762  
                           "// Right-to-left, Bottom-to-top\n" +
 1763  
                           "MigLayout rtlbLM = new MigLayout(\"rtl,btt\",\n" +
 1764  
                           "                                      \"[][grow,fill]\",\n" +
 1765  
                           "                                      \"\");\n" +
 1766  
                           "JPanel rtlbPanel = createTabPanel(rtlbLM);\n" +
 1767  
                           "addSeparator(rtlbPanel, \"Right to Left, Bottom to Top\");\n" +
 1768  
                           "rtlbPanel.add(createLabel(\"Level\"));\n" +
 1769  
                           "rtlbPanel.add(createTextField(\"\"), \"span,growx\");\n" +
 1770  
                           "rtlbPanel.add(createLabel(\"Radar\"));\n" +
 1771  
                           "rtlbPanel.add(createTextField(\"\"));\n" +
 1772  
                           "rtlbPanel.add(createTextField(\"\"));\n" +
 1773  
                           "\n" +
 1774  
                           "// Left-to-right, Bottom-to-top\n" +
 1775  
                           "MigLayout ltrbLM = new MigLayout(\"ltr,btt\",\n" +
 1776  
                           "                                      \"[][grow,fill]\",\n" +
 1777  
                           "                                      \"\");\n" +
 1778  
                           "JPanel ltrbPanel = createTabPanel(ltrbLM);\n" +
 1779  
                           "addSeparator(ltrbPanel, \"Left to Right, Bottom to Top\");\n" +
 1780  
                           "ltrbPanel.add(createLabel(\"Level\"));\n" +
 1781  
                           "ltrbPanel.add(createTextField(\"\"), \"span,growx\");\n" +
 1782  
                           "ltrbPanel.add(createLabel(\"Radar\"));\n" +
 1783  
                           "ltrbPanel.add(createTextField(\"\"));\n" +
 1784  
                           "ltrbPanel.add(createTextField(\"\"));\n" +
 1785  
                           "\n" +
 1786  
                           "mainPanel.add(defPanel);\n" +
 1787  
                           "mainPanel.add(rtlPanel);\n" +
 1788  
                           "mainPanel.add(rtlbPanel);\n" +
 1789  
                           "mainPanel.add(ltrbPanel);\n" +
 1790  
                           "\n" +
 1791  
                           "tabbedPane.addTab(\"Orientation\", mainPanel);");
 1792  
 
 1793  
                 return tabbedPane;
 1794  
         }
 1795  
 
 1796  
         public JComponent createCell_Position()
 1797  
         {
 1798  
                 JTabbedPane tabbedPane = new JTabbedPane();
 1799  
 
 1800  
                 // Absolute grid position
 1801  
                 MigLayout absLM = new MigLayout("",
 1802  
                                                 "[100:pref,fill]",
 1803  
                                                 "[100:pref,fill]");
 1804  
                 JPanel absPanel = createTabPanel(absLM);
 1805  
                 absPanel.add(createButton(), "cell 0 0");
 1806  
                 absPanel.add(createButton(), "cell 2 0");
 1807  
                 absPanel.add(createButton(), "cell 3 0");
 1808  
                 absPanel.add(createButton(), "cell 1 1");
 1809  
                 absPanel.add(createButton(), "cell 0 2");
 1810  
                 absPanel.add(createButton(), "cell 2 2");
 1811  
                 absPanel.add(createButton(), "cell 2 2");
 1812  
 
 1813  
 
 1814  
                 // Relative grid position with wrap
 1815  
                 MigLayout relAwLM = new MigLayout("wrap",
 1816  
                                                        "[100:pref,fill][100:pref,fill][100:pref,fill][100:pref,fill]",
 1817  
                                                        "[100:pref,fill]");
 1818  
                 JPanel relAwPanel = createTabPanel(relAwLM);
 1819  
                 relAwPanel.add(createButton());
 1820  
                 relAwPanel.add(createButton(), "skip");
 1821  
                 relAwPanel.add(createButton());
 1822  
                 relAwPanel.add(createButton(), "skip,wrap");
 1823  
                 relAwPanel.add(createButton());
 1824  
                 relAwPanel.add(createButton(), "skip,split");
 1825  
                 relAwPanel.add(createButton());
 1826  
 
 1827  
 
 1828  
                 // Relative grid position with manual wrap
 1829  
                 MigLayout relWLM = new MigLayout("",
 1830  
                                                       "[100:pref,fill]",
 1831  
                                                       "[100:pref,fill]");
 1832  
                 JPanel relWPanel = createTabPanel(relWLM);
 1833  
                 relWPanel.add(createButton());
 1834  
                 relWPanel.add(createButton(), "skip");
 1835  
                 relWPanel.add(createButton(), "wrap");
 1836  
                 relWPanel.add(createButton(), "skip,wrap");
 1837  
                 relWPanel.add(createButton());
 1838  
                 relWPanel.add(createButton(), "skip,split");
 1839  
 
 1840  
                 relWPanel.add(createButton());
 1841  
 
 1842  
 
 1843  
                 // Mixed relative and absolute grid position
 1844  
                 MigLayout mixLM = new MigLayout("",
 1845  
                                                 "[100:pref,fill]",
 1846  
                                                 "[100:pref,fill]");
 1847  
                 JPanel mixPanel = createTabPanel(mixLM);
 1848  
                 mixPanel.add(createButton());
 1849  
                 mixPanel.add(createButton(), "cell 2 0");
 1850  
                 mixPanel.add(createButton());
 1851  
                 mixPanel.add(createButton(), "cell 1 1,wrap");
 1852  
                 mixPanel.add(createButton());
 1853  
                 mixPanel.add(createButton(), "cell 2 2,split");
 1854  
                 mixPanel.add(createButton());
 1855  
 
 1856  
                 tabbedPane.addTab("Absolute", absPanel);
 1857  
                 tabbedPane.addTab("Relative + Wrap", relAwPanel);
 1858  
                 tabbedPane.addTab("Relative", relWPanel);
 1859  
                 tabbedPane.addTab("Mixed", mixPanel);
 1860  
 
 1861  
                 // Disregard. Just forgetting the source code text close to the source code.
 1862  
                 setSource("\t\tJTabbedPane tabbedPane = new JTabbedPane();\n" +
 1863  
                           "\n" +
 1864  
                           "\t\t// Absolute grid position\n" +
 1865  
                           "\t\tMigLayout absLM = new MigLayout(\"\",\n" +
 1866  
                           "\t\t                                \"[100:pref,fill]\",\n" +
 1867  
                           "\t\t                                \"[100:pref,fill]\");\n" +
 1868  
                           "\t\tJPanel absPanel = createTabPanel(absLM);\n" +
 1869  
                           "\t\tabsPanel.add(createPanel(), \"cell 0 0\");\n" +
 1870  
                           "\t\tabsPanel.add(createPanel(), \"cell 2 0\");\n" +
 1871  
                           "\t\tabsPanel.add(createPanel(), \"cell 3 0\");\n" +
 1872  
                           "\t\tabsPanel.add(createPanel(), \"cell 1 1\");\n" +
 1873  
                           "\t\tabsPanel.add(createPanel(), \"cell 0 2\");\n" +
 1874  
                           "\t\tabsPanel.add(createPanel(), \"cell 2 2\");\n" +
 1875  
                           "\t\tabsPanel.add(createPanel(), \"cell 2 2\");\n" +
 1876  
                           "\n" +
 1877  
                           "\n" +
 1878  
                           "\t\t// Relative grid position with wrap\n" +
 1879  
                           "\t\tMigLayout relAwLM = new MigLayout(\"wrap\",\n" +
 1880  
                           "\t\t                                       \"[100:pref,fill][100:pref,fill][100:pref,fill][100:pref,fill]\",\n" +
 1881  
                           "\t\t                                       \"[100:pref,fill]\");\n" +
 1882  
                           "\t\tJPanel relAwPanel = createTabPanel(relAwLM);\n" +
 1883  
                           "\t\trelAwPanel.add(createPanel());\n" +
 1884  
                           "\t\trelAwPanel.add(createPanel(), \"skip\");\n" +
 1885  
                           "\t\trelAwPanel.add(createPanel());\n" +
 1886  
                           "\t\trelAwPanel.add(createPanel(), \"skip,wrap\");\n" +
 1887  
                           "\t\trelAwPanel.add(createPanel());\n" +
 1888  
                           "\t\trelAwPanel.add(createPanel(), \"skip,split\");\n" +
 1889  
                           "\t\trelAwPanel.add(createPanel());\n" +
 1890  
                           "\n" +
 1891  
                           "\n" +
 1892  
                           "\t\t// Relative grid position with manual wrap\n" +
 1893  
                           "\t\tMigLayout relWLM = new MigLayout(\"\",\n" +
 1894  
                           "\t\t                                      \"[100:pref,fill]\",\n" +
 1895  
                           "\t\t                                      \"[100:pref,fill]\");\n" +
 1896  
                           "\t\tJPanel relWPanel = createTabPanel(relWLM);\n" +
 1897  
                           "\t\trelWPanel.add(createPanel());\n" +
 1898  
                           "\t\trelWPanel.add(createPanel(), \"skip\");\n" +
 1899  
                           "\t\trelWPanel.add(createPanel(), \"wrap\");\n" +
 1900  
                           "\t\trelWPanel.add(createPanel(), \"skip,wrap\");\n" +
 1901  
                           "\t\trelWPanel.add(createPanel());\n" +
 1902  
                           "\t\trelWPanel.add(createPanel(), \"skip,split\");\n" +
 1903  
                           "\n" +
 1904  
                           "\t\trelWPanel.add(createPanel());\n" +
 1905  
                           "\n" +
 1906  
                           "\n" +
 1907  
                           "\t\t// Mixed relative and absolute grid position\n" +
 1908  
                           "\t\tMigLayout mixLM = new MigLayout(\"\",\n" +
 1909  
                           "\t\t                                \"[100:pref,fill]\",\n" +
 1910  
                           "\t\t                                \"[100:pref,fill]\");\n" +
 1911  
                           "\t\tJPanel mixPanel = createTabPanel(mixLM);\n" +
 1912  
                           "\t\tmixPanel.add(createPanel());\n" +
 1913  
                           "\t\tmixPanel.add(createPanel(), \"cell 2 0\");\n" +
 1914  
                           "\t\tmixPanel.add(createPanel());\n" +
 1915  
                           "\t\tmixPanel.add(createPanel(), \"cell 1 1,wrap\");\n" +
 1916  
                           "\t\tmixPanel.add(createPanel());\n" +
 1917  
                           "\t\tmixPanel.add(createPanel(), \"cell 2 2,split\");\n" +
 1918  
                           "\t\tmixPanel.add(createPanel());\n" +
 1919  
                           "\n" +
 1920  
                           "\t\ttabbedPane.addTab(\"Absolute\", absPanel);\n" +
 1921  
                           "\t\ttabbedPane.addTab(\"Relative + Wrap\", relAwPanel);\n" +
 1922  
                           "\t\ttabbedPane.addTab(\"Relative\", relWPanel);\n" +
 1923  
                           "\t\ttabbedPane.addTab(\"Mixed\", mixPanel);");
 1924  
 
 1925  
                 return tabbedPane;
 1926  
         }
 1927  
 
 1928  
         public JComponent createPlain()
 1929  
         {
 1930  
                 return createPlainImpl(false);
 1931  
         }
 1932  
 
 1933  
         private JComponent createPlainImpl(boolean debug)
 1934  
         {
 1935  
                 JTabbedPane tabbedPane = new JTabbedPane();
 1936  
 
 1937  
                 MigLayout lm = new MigLayout((debug && benchRuns == 0 ? "debug, inset 20" : "ins 20"), "[para]0[][100lp, fill][60lp][95lp, fill]", "");
 1938  
                 JPanel panel = createTabPanel(lm);
 1939  
 
 1940  
                 addSeparator(panel, "Manufacturer");
 1941  
 
 1942  
                 panel.add(createLabel("Company"),      "skip");
 1943  
                 panel.add(createTextField(""),         "span, growx");
 1944  
                 panel.add(createLabel("Contact"),      "skip");
 1945  
                 panel.add(createTextField(""),         "span, growx");
 1946  
                 panel.add(createLabel("Order No"),     "skip");
 1947  
                 panel.add(createTextField(15),         "wrap para");
 1948  
 
 1949  
                 addSeparator(panel, "Inspector");
 1950  
 
 1951  
                 panel.add(createLabel("Name"),         "skip");
 1952  
                 panel.add(createTextField(""),         "span, growx");
 1953  
                 panel.add(createLabel("Reference No"), "skip");
 1954  
                 panel.add(createTextField(""),         "wrap");
 1955  
                 panel.add(createLabel("Status"),       "skip");
 1956  
                 panel.add(createCombo(new String[] {"In Progress", "Finnished", "Released"}), "wrap para");
 1957  
 
 1958  
                 addSeparator(panel, "Ship");
 1959  
 
 1960  
                 panel.add(createLabel("Shipyard"),     "skip");
 1961  
                 panel.add(createTextField(""),         "span, growx");
 1962  
                 panel.add(createLabel("Register No"),  "skip");
 1963  
                 panel.add(createTextField(""));
 1964  
                 panel.add(createLabel("Hull No"),      "right");
 1965  
                 panel.add(createTextField(15), "wrap");
 1966  
                 panel.add(createLabel("Project StructureType"), "skip");
 1967  
                 panel.add(createCombo(new String[] {"New Building", "Convention", "Repair"}));
 1968  
 
 1969  
                 if (debug)
 1970  
                         panel.add(createLabel("Red is cell bounds. Blue is component bounds."), "newline,ax left,span,gaptop 40,");
 1971  
 
 1972  
                 tabbedPane.addTab("Plain", panel);
 1973  
 
 1974  
                 // Disregard. Just forgetting the source code text close to the source code.
 1975  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 1976  
                           "\n" +
 1977  
                           "MigLayout lm = new MigLayout((debug && benchRuns == 0 ? \"debug, inset 20\" : \"ins 20\"), \"[para]0[][100lp, fill][60lp][95lp, fill]\", \"\");\n" +
 1978  
                           "JPanel panel = createTabPanel(lm);\n" +
 1979  
                           "\n" +
 1980  
                           "addSeparator(panel, \"Manufacturer\");\n" +
 1981  
                           "\n" +
 1982  
                           "panel.add(createLabel(\"Company\"),   \"skip\");\n" +
 1983  
                           "panel.add(createTextField(\"\"),      \"span, growx\");\n" +
 1984  
                           "panel.add(createLabel(\"Contact\"),   \"skip\");\n" +
 1985  
                           "panel.add(createTextField(\"\"),      \"span, growx\");\n" +
 1986  
                           "panel.add(createLabel(\"Order No\"),  \"skip\");\n" +
 1987  
                           "panel.add(createTextField(15),      \"wrap para\");\n" +
 1988  
                           "\n" +
 1989  
                           "addSeparator(panel, \"Inspector\");\n" +
 1990  
                           "\n" +
 1991  
                           "panel.add(createLabel(\"Name\"),         \"skip\");\n" +
 1992  
                           "panel.add(createTextField(\"\"),         \"span, growx\");\n" +
 1993  
                           "panel.add(createLabel(\"Reference No\"), \"skip\");\n" +
 1994  
                           "panel.add(createTextField(\"\"),         \"wrap\");\n" +
 1995  
                           "panel.add(createLabel(\"Status\"),       \"skip\");\n" +
 1996  
                           "panel.add(createCombo(new String[] {\"In Progress\", \"Finnished\", \"Released\"}), \"wrap para\");\n" +
 1997  
                           "\n" +
 1998  
                           "addSeparator(panel, \"Ship\");\n" +
 1999  
                           "\n" +
 2000  
                           "panel.add(createLabel(\"Shipyard\"),     \"skip\");\n" +
 2001  
                           "panel.add(createTextField(\"\"),         \"span, growx\");\n" +
 2002  
                           "panel.add(createLabel(\"Register No\"),  \"skip\");\n" +
 2003  
                           "panel.add(createTextField(\"\"));\n" +
 2004  
                           "panel.add(createLabel(\"Hull No\"),      \"right\");\n" +
 2005  
                           "panel.add(createTextField(15), \"wrap\");\n" +
 2006  
                           "panel.add(createLabel(\"Project StructureType\"), \"skip\");\n" +
 2007  
                           "panel.add(createCombo(new String[] {\"New Building\", \"Convention\", \"Repair\"}));\n" +
 2008  
                           "\n" +
 2009  
                           "if (debug)\n" +
 2010  
                           "\tpanel.add(createLabel(\"Red is cell bounds. Blue is component bounds.\"), \"newline,ax left,span,gaptop 40,\");\n" +
 2011  
                           "\n" +
 2012  
                           "tabbedPane.addTab(\"Plain\", panel);");
 2013  
 
 2014  
                 return tabbedPane;
 2015  
         }
 2016  
 
 2017  
         public JComponent createBound_Sizes()
 2018  
         {
 2019  
                 JTabbedPane tabbedPane = new JTabbedPane();
 2020  
 
 2021  
                 for (int i = 0; i < 2; i++) {   // Jumping for 0 and Stable for 1
 2022  
                         String colConstr = i == 0 ? "[right][300]" : "[right, 100lp:pref][300]";
 2023  
 
 2024  
                         MigLayout LM1 = new MigLayout("wrap", colConstr, "");
 2025  
                         JPanel panel1 = createTabPanel(LM1);
 2026  
                         panel1.add(createLabel("File Number:"));
 2027  
                         panel1.add(createTextField(""), "growx");
 2028  
                         panel1.add(createLabel("RFQ Number:"));
 2029  
                         panel1.add(createTextField(""), "growx");
 2030  
                         panel1.add(createLabel("Entry Date:"));
 2031  
                         panel1.add(createTextField(6));
 2032  
                         panel1.add(createLabel("Sales Person:"));
 2033  
                         panel1.add(createTextField(""), "growx");
 2034  
 
 2035  
                         MigLayout LM2 = new MigLayout("wrap", colConstr, "");
 2036  
                         JPanel panel2 = createTabPanel(LM2);
 2037  
                         panel2.add(createLabel("Shipper:"));
 2038  
                         panel2.add(createTextField(6), "split 2");
 2039  
                         panel2.add(createTextField(""), "growx");
 2040  
                         panel2.add(createLabel("Consignee:"));
 2041  
                         panel2.add(createTextField(6), "split 2");
 2042  
                         panel2.add(createTextField(""), "growx");
 2043  
                         panel2.add(createLabel("Departure:"));
 2044  
                         panel2.add(createTextField(6), "split 2");
 2045  
                         panel2.add(createTextField(""), "growx");
 2046  
                         panel2.add(createLabel("Destination:"));
 2047  
                         panel2.add(createTextField(6), "split 2");
 2048  
                         panel2.add(createTextField(""), "growx");
 2049  
 
 2050  
                         tabbedPane.addTab(i == 0 ? "Jumping 1" : "Stable 1", panel1);
 2051  
                         tabbedPane.addTab(i == 0 ? "Jumping 2" : "Stable 2", panel2);
 2052  
                 }
 2053  
 
 2054  
                 // Disregard. Just forgetting the source code text close to the source code.
 2055  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 2056  
                           "\n" +
 2057  
                           "for (int i = 0; i < 2; i++) {   // Jumping for 0 and Stable for 1\n" +
 2058  
                           "\tString colConstr = i == 0 ? \"[right][300]\" : \"[right, 100lp:pref][300]\";\n" +
 2059  
                           "\n" +
 2060  
                           "\tMigLayout LM1 = new MigLayout(\"wrap\", colConstr, \"\");\n" +
 2061  
                           "\tJPanel panel1 = createTabPanel(LM1);\n" +
 2062  
                           "\tpanel1.add(createLabel(\"File Number:\"));\n" +
 2063  
                           "\tpanel1.add(createTextField(\"\"), \"growx\");\n" +
 2064  
                           "\tpanel1.add(createLabel(\"RFQ Number:\"));\n" +
 2065  
                           "\tpanel1.add(createTextField(\"\"), \"growx\");\n" +
 2066  
                           "\tpanel1.add(createLabel(\"Entry Date:\"));\n" +
 2067  
                           "\tpanel1.add(createTextField(6));\n" +
 2068  
                           "\tpanel1.add(createLabel(\"Sales Person:\"));\n" +
 2069  
                           "\tpanel1.add(createTextField(\"\"), \"growx\");\n" +
 2070  
                           "\n" +
 2071  
                           "\tMigLayout LM2 = new MigLayout(\"wrap\", colConstr, \"\");\n" +
 2072  
                           "\tJPanel panel2 = createTabPanel(LM2);\n" +
 2073  
                           "\tpanel2.add(createLabel(\"Shipper:\"));\n" +
 2074  
                           "\tpanel2.add(createTextField(6), \"split 2\");\n" +
 2075  
                           "\tpanel2.add(createTextField(\"\"), \"growx\");\n" +
 2076  
                           "\tpanel2.add(createLabel(\"Consignee:\"));\n" +
 2077  
                           "\tpanel2.add(createTextField(6), \"split 2\");\n" +
 2078  
                           "\tpanel2.add(createTextField(\"\"), \"growx\");\n" +
 2079  
                           "\tpanel2.add(createLabel(\"Departure:\"));\n" +
 2080  
                           "\tpanel2.add(createTextField(6), \"split 2\");\n" +
 2081  
                           "\tpanel2.add(createTextField(\"\"), \"growx\");\n" +
 2082  
                           "\tpanel2.add(createLabel(\"Destination:\"));\n" +
 2083  
                           "\tpanel2.add(createTextField(6), \"split 2\");\n" +
 2084  
                           "\tpanel2.add(createTextField(\"\"), \"growx\");\n" +
 2085  
                           "\n" +
 2086  
                           "\ttabbedPane.addTab(i == 0 ? \"Jumping 1\" : \"Stable 2\", panel1);\n" +
 2087  
                           "\ttabbedPane.addTab(i == 0 ? \"Jumping 2\" : \"Stable 2\", panel2);\n" +
 2088  
                           "}");
 2089  
 
 2090  
                 return tabbedPane;
 2091  
         }
 2092  
 
 2093  
         public JComponent createComponent_Sizes()
 2094  
         {
 2095  
                 JTabbedPane tabbedPane = new JTabbedPane();
 2096  
 
 2097  
                 MigLayout LM = new MigLayout("wrap", "[right][0:pref,grow]", "");
 2098  
 
 2099  
                 JPanel panel = createTabPanel(LM);
 2100  
                 JScrollPane descrText = createTextAreaScroll("Use slider to see how the components grow and shrink depending on the constraints set on them.", 0, 0, false);
 2101  
 
 2102  
                 descrText.setOpaque(OPAQUE);
 2103  
                 descrText.setBorder(new EmptyBorder(10, 10, 10, 10));
 2104  
                 ((JTextArea) descrText.getViewport().getView()).setOpaque(OPAQUE);
 2105  
                 descrText.getViewport().setOpaque(OPAQUE);
 2106  
 
 2107  
                 JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, panel, descrText);
 2108  
                 splitPane.setOpaque(OPAQUE);
 2109  
                 splitPane.setBorder(null);
 2110  
 
 2111  
                 panel.add(createLabel("\"\""));
 2112  
                 panel.add(createTextField(""));
 2113  
                 panel.add(createLabel("\"min!\""));
 2114  
                 panel.add(createTextField("3", 3), "width min!");
 2115  
                 panel.add(createLabel("\"pref!\""));
 2116  
                 panel.add(createTextField("3", 3), "width pref!");
 2117  
                 panel.add(createLabel("\"min:pref\""));
 2118  
                 panel.add(createTextField("8", 8), "width min:pref");
 2119  
                 panel.add(createLabel("\"min:100:150\""));
 2120  
                 panel.add(createTextField("8", 8), "width min:100:150");
 2121  
                 panel.add(createLabel("\"min:100:150, growx\""));
 2122  
                 panel.add(createTextField("8", 8), "width min:100:150, growx");
 2123  
                 panel.add(createLabel("\"min:100, growx\""));
 2124  
                 panel.add(createTextField("8", 8), "width min:100, growx");
 2125  
                 panel.add(createLabel("\"40!\""));
 2126  
                 panel.add(createTextField("8", 8), "width 40!");
 2127  
                 panel.add(createLabel("\"40:40:40\""));
 2128  
                 panel.add(createTextField("8", 8), "width 40:40:40");
 2129  
 
 2130  
                 tabbedPane.addTab("Component Sizes", splitPane);
 2131  
 
 2132  
                 // Disregard. Just forgetting the source code text close to the source code.
 2133  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 2134  
                           "\n" +
 2135  
                           "\t\tMigLayout LM = new MigLayout(\"wrap\", \"[right][0:pref,grow]\", \"\");\n" +
 2136  
                           "\n" +
 2137  
                           "\t\tJPanel panel = createTabPanel(LM);\n" +
 2138  
                           "\t\tJScrollPane descrText = createTextAreaScroll(\"Use slider to see how the components grow and shrink depending on the constraints set on them.\", 0, 0, false);\n" +
 2139  
                           "\n" +
 2140  
                           "\t\tdescrText.setOpaque(OPAQUE);\n" +
 2141  
                           "\t\tdescrText.setBorder(new EmptyBorder(10, 10, 10, 10));\n" +
 2142  
                           "\t\t((JTextArea) descrText.getViewport().getView()).setOpaque(OPAQUE);\n" +
 2143  
                           "\t\tdescrText.getViewport().setOpaque(OPAQUE);\n" +
 2144  
                           "\n" +
 2145  
                           "\t\tJSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, panel, descrText);\n" +
 2146  
                           "\t\tsplitPane.setOpaque(OPAQUE);\n" +
 2147  
                           "\t\tsplitPane.setBorder(null);\n" +
 2148  
                           "\n" +
 2149  
                           "\t\tpanel.add(createLabel(\"\\\"\\\"\"));\n" +
 2150  
                           "\t\tpanel.add(createTextField(\"\"));\n" +
 2151  
                           "\t\tpanel.add(createLabel(\"\\\"min!\\\"\"));\n" +
 2152  
                           "\t\tpanel.add(createTextField(\"3\", 3), \"width min!\");\n" +
 2153  
                           "\t\tpanel.add(createLabel(\"\\\"pref!\\\"\"));\n" +
 2154  
                           "\t\tpanel.add(createTextField(\"3\", 3), \"width pref!\");\n" +
 2155  
                           "\t\tpanel.add(createLabel(\"\\\"min:pref\\\"\"));\n" +
 2156  
                           "\t\tpanel.add(createTextField(\"8\", 8), \"width min:pref\");\n" +
 2157  
                           "\t\tpanel.add(createLabel(\"\\\"min:100:150\\\"\"));\n" +
 2158  
                           "\t\tpanel.add(createTextField(\"8\", 8), \"width min:100:150\");\n" +
 2159  
                           "\t\tpanel.add(createLabel(\"\\\"min:100:150, growx\\\"\"));\n" +
 2160  
                           "\t\tpanel.add(createTextField(\"8\", 8), \"width min:100:150, growx\");\n" +
 2161  
                           "\t\tpanel.add(createLabel(\"\\\"min:100, growx\\\"\"));\n" +
 2162  
                           "\t\tpanel.add(createTextField(\"8\", 8), \"width min:100, growx\");\n" +
 2163  
                           "\t\tpanel.add(createLabel(\"\\\"40!\\\"\"));\n" +
 2164  
                           "\t\tpanel.add(createTextField(\"8\", 8), \"width 40!\");\n" +
 2165  
                           "\t\tpanel.add(createLabel(\"\\\"40:40:40\\\"\"));\n" +
 2166  
                           "\t\tpanel.add(createTextField(\"8\", 8), \"width 40:40:40\");\n" +
 2167  
                           "\n" +
 2168  
                           "\t\ttabbedPane.addTab(\"Component Sizes\", splitPane);");
 2169  
 
 2170  
                 return tabbedPane;
 2171  
         }
 2172  
 
 2173  
         public JComponent createCell_Alignments()
 2174  
         {
 2175  
                 JTabbedPane tabbedPane = new JTabbedPane();
 2176  
 
 2177  
                 // Horizontal
 2178  
                 MigLayout hLM = new MigLayout("wrap",
 2179  
                                               "[grow,left][grow,center][grow,right][grow,fill,center]",
 2180  
                                               "[]unrel[][]");
 2181  
                 JPanel hPanel = createTabPanel(hLM);
 2182  
                 String[] sizes = new String[] {"", "growx", "growx 0", "left", "center", "right", "leading", "trailing"};
 2183  
                 hPanel.add(createLabel("[left]"), "c");
 2184  
                 hPanel.add(createLabel("[center]"), "c");
 2185  
                 hPanel.add(createLabel("[right]"), "c");
 2186  
                 hPanel.add(createLabel("[fill,center]"), "c, growx 0");
 2187  
 
 2188  
                 for (int r = 0; r < sizes.length; r++) {
 2189  
                         for (int c = 0; c < 4; c++) {
 2190  
                                 String text = sizes[r].length() > 0 ? sizes[r] : "default";
 2191  
                                 hPanel.add(createButton(text), sizes[r]);
 2192  
                         }
 2193  
                 }
 2194  
 
 2195  
                 // Vertical
 2196  
                 MigLayout vLM = new MigLayout("wrap,flowy",
 2197  
                                                    "[right][]",
 2198  
                                                    "[grow,top][grow,center][grow,bottom][grow,fill,bottom][grow,fill,baseline]");
 2199  
                 JPanel vPanel = createTabPanel(vLM);
 2200  
                 String[] vSizes = new String[] {"", "growy", "growy 0", "top", "aligny center", "bottom"};
 2201  
                 vPanel.add(createLabel("[top]"), "aligny center");
 2202  
                 vPanel.add(createLabel("[center]"), "aligny center");
 2203  
                 vPanel.add(createLabel("[bottom]"), "aligny center");
 2204  
                 vPanel.add(createLabel("[fill, bottom]"), "aligny center, growy 0");
 2205  
                 vPanel.add(createLabel("[fill, baseline]"), "aligny center");
 2206  
 
 2207  
                 for (int c = 0; c < vSizes.length; c++) {
 2208  
                         for (int r = 0; r < 5; r++) {
 2209  
                                 String text = vSizes[c].length() > 0 ? vSizes[c] : "default";
 2210  
                                 JButton b = createButton(text);
 2211  
                                 if (r == 4 && c <= 1)
 2212  
                                         b.setFont(new Font("sansserif", Font.PLAIN, 16 + c * 5));
 2213  
                                 vPanel.add(b, vSizes[c]);
 2214  
                         }
 2215  
                 }
 2216  
 
 2217  
                 tabbedPane.addTab("Horizontal", hPanel);
 2218  
                 tabbedPane.addTab("Vertical", vPanel);
 2219  
 
 2220  
                 // Disregard. Just forgetting the source code text close to the source code.
 2221  
                 setSource("JTabbedPane tabbedPane = new JTabbedPane();\n" +
 2222  
                           "\n" +
 2223  
                           "// Horizontal\n" +
 2224  
                           "MigLayout hLM = new MigLayout(\"wrap\",\n" +
 2225  
                           "                              \"[grow,left][grow,center][grow,right][grow,fill,center]\",\n" +
 2226  
                           "                              \"[]unrel[][]\");\n" +
 2227  
                           "JPanel hPanel = createTabPanel(hLM);\n" +
 2228  
                           "String[] sizes = new String[] {\"\", \"growx\", \"growx 0\", \"left\", \"center\", \"right\", \"leading\", \"trailing\"};\n" +
 2229  
                           "hPanel.add(createLabel(\"[left]\"), \"c\");\n" +
 2230  
                           "hPanel.add(createLabel(\"[center]\"), \"c\");\n" +
 2231  
                           "hPanel.add(createLabel(\"[right]\"), \"c\");\n" +
 2232  
                           "hPanel.add(createLabel(\"[fill,center]\"), \"c, growx 0\");\n" +
 2233  
                           "\n" +
 2234  
                           "for (int r = 0; r < sizes.length; r++) {\n" +
 2235  
                           "\tfor (int c = 0; c < 4; c++) {\n" +
 2236  
                           "\t\tString text = sizes[r].length() > 0 ? sizes[r] : \"default\";\n" +
 2237  
                           "\t\thPanel.add(createButton(text), sizes[r]);\n" +
 2238  
                           "\t}\n" +
 2239  
                           "}\n" +
 2240  
                           "\n" +
 2241  
                           "// Vertical\n" +
 2242  
                           "MigLayout vLM = new MigLayout(\"wrap,flowy\",\n" +
 2243  
                           "                                   \"[right][]\",\n" +
 2244  
                           "                                   \"[grow,top][grow,center][grow,bottom][grow,fill,bottom][grow,fill,baseline]\");\n" +
 2245  
                           "JPanel vPanel = createTabPanel(vLM);\n" +
 2246  
                           "String[] vSizes = new String[] {\"\", \"growy\", \"growy 0\", \"top\", \"center\", \"bottom\"};\n" +
 2247  
                           "vPanel.add(createLabel(\"[top]\"), \"center\");\n" +
 2248  
                           "vPanel.add(createLabel(\"[center]\"), \"center\");\n" +
 2249  
                           "vPanel.add(createLabel(\"[bottom]\"), \"center\");\n" +
 2250  
                           "vPanel.add(createLabel(\"[fill, bottom]\"), \"center, growy 0\");\n" +
 2251  
                           "vPanel.add(createLabel(\"[fill, baseline]\"), \"center\");\n" +
 2252  
                           "\n" +
 2253