summaryrefslogtreecommitdiff
path: root/prototypes/miglayout/net/miginfocom/demo/SwtDemo.java
blob: 76edda009db4ab409faec759fe5109909f491c3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
package net.miginfocom.demo;

import net.miginfocom.layout.*;
import net.miginfocom.swt.MigLayout;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Random;

/*
 * License (BSD):
 * ==============
 *
 * Copyright (c) 2004, Mikael Grev, MiG InfoCom AB. (miglayout (at) miginfocom (dot) com)
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright notice, this list
 * of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this
 * list of conditions and the following disclaimer in the documentation and/or other
 * materials provided with the distribution.
 * Neither the name of the MiG InfoCom AB nor the names of its contributors may be
 * used to endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
 * OF SUCH DAMAGE.
 *
 * @version 1.0
 * @author Mikael Grev, MiG InfoCom AB
 *         Date: 2006-sep-08
 */
public class SwtDemo
{
	public static final int SELECTED_INDEX = 0;

	private static final String[][] panels = new String[][] {
//			{"Test", "Test, Disregard"},
			{"Welcome", "\n\n         \"MigLayout makes complex layouts easy and normal layouts one-liners.\""},
			{"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."},
			{"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."},
			{"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."},
			{"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."},
			{"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."},
			{"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."},
			{"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 " +
							"components shrink to their inherent (or specified) minimum size, but they don't grow."},
			{"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."},
			{"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."},
			{"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 " +
						 "the same minimum and preferred size (the largest within the group). Size-groups can be set for the width, height or both."},
			{"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)."},
			{"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 " +
								"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."},
			{"Bound Sizes", "Shows how to create columns that are stable between tabs using minimum sizes."},
			{"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."},
			{"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 " +
							"pick up if right-to-left is to be used depending on the ComponentWrapper, but it can also be manually set for every layout."},
			{"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" +
								  "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. " +
								  "Absolute positioned components will be taken into account when calculating the container's preferred size."},
			{"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." +
								"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" +
								"Since the links can be combined with any expression (such as 'butt1.x+10' or 'max(button.x, 200)' the links are very customizable."},
			{"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 " +
						"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 " +
						"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."},
			{"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."},
			{"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 " +
					  "continuously repaint the panel with debug information on top. This means you don't have to change your code to debug!"},
			{"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." +
			                    "The source code is for bothe 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"},
			{"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."},
			{"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."},
	};

	private static int DOUBLE_BUFFER = 0;//SWT.DOUBLE_BUFFERED;

	private static int benchRuns = 0;
	private static long startupMillis = 0;
	private static long timeToShowMillis = 0;
	private static long benchRunTime = 0;
	private static String benchOutFileName = null;
	private static boolean append = false;

	private static long lastRunTimeStart = 0;
	private static StringBuffer runTimeSB = null;

	private static Display display = null;

	public static void main(String[] args)
	{
		startupMillis = System.currentTimeMillis();

		if (args.length > 0) {
			for (int i = 0; i < args.length; i++) {
				String arg = args[i].trim();
				if (arg.startsWith("-bench")) {
					benchRuns = 10;
					try {
						if (arg.length() > 6)
							benchRuns = Integer.parseInt(arg.substring(6));
					} catch (Exception ex) {}
				} else if (arg.startsWith("-bout")) {
					benchOutFileName = arg.substring(5);
				} else if (arg.startsWith("-append")) {
					append = true;
				} else if (arg.startsWith("-verbose")) {
					runTimeSB = new StringBuffer(256);
				} else {
					System.out.println("Usage: [-bench[#_of_runs]] [-bout[benchmark_results_filename]] [-append]\n" +
					                   " -bench Run demo as benchmark. Run count can be appended. 10 is default.\n" +
					                   " -bout  Benchmark results output filename.\n" +
					                   " -append Appends the result to the \"-bout\" file.\n" +
					                   " -verbose Print the times of every run.\n" +
					                   "\nExamples:\n" +
					                   " java -jar swtdemoapp.jar -bench -boutC:/bench.txt -append\n" +
					                   " java -jar swtdemoapp.jar -bench20\n" +
					                   "NOTE! swt-win32-3232.dll must be in the current directory!");
					System.exit(0);
				}
			}
		}

		if (benchRuns > 0)
			LayoutUtil.setDesignTime(null, true);

		new SwtDemo();
	}

	final List pickerList;
	final Composite layoutDisplayPanel;
	final StyledText descrTextArea;

	public SwtDemo()
	{
		display = new Display();
		final Shell shell = new Shell();

		shell.setLayout(new MigLayout("wrap", "[]u[grow,fill]", "[grow,fill][pref!]"));
		shell.setText("MigLayout SWT Demo v2.5 - Mig Layout v" + LayoutUtil.getVersion());

		TabFolder layoutPickerTabPane = new TabFolder(shell, DOUBLE_BUFFER);
		layoutPickerTabPane.setLayoutData("spany,grow");
			pickerList = new List(layoutPickerTabPane, SWT.SINGLE | DOUBLE_BUFFER);
			deriveFont(pickerList, SWT.BOLD, -1);
			TabItem tab = new TabItem(layoutPickerTabPane, DOUBLE_BUFFER);
			tab.setControl(pickerList);
			tab.setText("Example Browser");
			for (int i = 0; i < panels.length; i++)
				pickerList.add(panels[i][0]);

		layoutDisplayPanel = new Composite(shell, DOUBLE_BUFFER);
		layoutDisplayPanel.setLayout(new MigLayout("fill, insets 0"));

		TabFolder descriptionTabPane = new TabFolder(shell, DOUBLE_BUFFER);
		descriptionTabPane.setLayoutData("growx,hmin 120,w 500:500");
			descrTextArea = createTextArea(descriptionTabPane, "", "", SWT.MULTI | SWT.WRAP);
			tab = new TabItem(descriptionTabPane, DOUBLE_BUFFER);
			tab.setControl(descrTextArea);
			tab.setText("Description");

		pickerList.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e) {
				dispatchSelection();
			}
		});

		shell.setSize(900, 650);
		shell.open();

		shell.layout();


		if (benchRuns > 0) {
			doBenchmark();
		} else {
			pickerList.select(SELECTED_INDEX);
			dispatchSelection();

			display.addFilter(SWT.KeyDown, new Listener() {

				public void handleEvent(Event e)
				{
					if (e.character == 'b') {
						startupMillis = System.currentTimeMillis();
						timeToShowMillis = System.currentTimeMillis() - startupMillis;
						benchRuns = 1;
						doBenchmark();
					}
				}
			});
		}

		while(!shell.isDisposed()){
			if(!display.readAndDispatch())
				display.sleep();
		}

		display.dispose();
	}

	private static Control[] comps = null;  // thread hack...
	private static Control[] tabs = null;     // thread hack...

	private void doBenchmark()
	{
		final int pCnt = pickerList.getItemCount();
		Thread benchThread = new Thread() {
				public void run()
				{
					for (int j = 0; j < benchRuns; j++) {
						lastRunTimeStart = System.currentTimeMillis();
						final int jj = j;
						for (int i = 0; i < pCnt; i++) {
							final int ii = i;
							try {
								 display.syncExec(new Runnable() {
									  public void run () {
										  pickerList.setSelection(ii);
										  dispatchSelection();
									  }
								   });
							} catch (Exception e) {
								e.printStackTrace();
							}

							display.syncExec(new Runnable() {
								 public void run() {
									 comps = layoutDisplayPanel.getChildren();
								 }
							 });

							for (int cIx = 0; cIx < comps.length; cIx++) {

								if (comps[cIx] instanceof TabFolder) {
									final TabFolder tp = (TabFolder) comps[cIx];

									display.syncExec(new Runnable() {
										 public void run() {
											 tabs = tp.getTabList();
										 }
									 });

									for (int k = 0; k < tabs.length; k++) {
										final int kk = k;
										try {
											display.syncExec(new Runnable() {
												 public void run() {
													 tp.setSelection(kk);

													 if (timeToShowMillis == 0)
														 timeToShowMillis = System.currentTimeMillis() - startupMillis;
												 }
											 });
										} catch (Exception e) {
											e.printStackTrace();
										};
									}
								}
							}
						}
						if (runTimeSB != null) {
						   runTimeSB.append("Run ").append(jj).append(": ");
						   runTimeSB.append(System.currentTimeMillis() - lastRunTimeStart).append(" millis.\n");
						}
					}

					benchRunTime = System.currentTimeMillis() - startupMillis - timeToShowMillis;

					final String message = "Java Version:       " + System.getProperty("java.version") + "\n" +
					                 "Time to Show:       " + timeToShowMillis + " millis.\n" +
					                 (runTimeSB != null ? runTimeSB.toString() : "") +
					                 "Benchmark Run Time: " + benchRunTime + " millis.\n" +
					                 "Average Run Time:   " + (benchRunTime / benchRuns) + " millis (" + benchRuns + " runs).\n\n";

					display.syncExec(new Runnable() {
						 public void run() {
							 if (benchOutFileName == null) {
								 MessageBox messageBox = new MessageBox(display.getActiveShell(), SWT.OK | SWT.ICON_INFORMATION);
								 messageBox.setText("Results");
								 messageBox.setMessage(message);
								 messageBox.open();
							 } else {
								 FileWriter fw = null;
								 try {
									 fw = new FileWriter(benchOutFileName, append);
									 fw.write(message);
								 } catch(IOException ex) {
									 ex.printStackTrace();
								 } finally {
									 if (fw != null)
										 try {fw.close();} catch(IOException ex) {}
								 }
							 }
						 }
					 });

					System.out.println(message);

					if (benchOutFileName != null)
						System.exit(0);
				}
			};
			benchThread.start();
	}

	private void dispatchSelection()
	{
		int ix = pickerList.getSelectionIndex();
		if (ix == -1)
			return;

		String methodName = "create" + panels[ix][0].replace(' ', '_');
		Control[] children = layoutDisplayPanel.getChildren();
		for (int i = 0; i < children.length; i++)
			children[i].dispose();

		try {
			Control child = (Control) SwtDemo.class.getMethod(methodName, new Class[] {Composite.class}).invoke(SwtDemo.this, new Object[] {layoutDisplayPanel});
			child.setLayoutData("grow, wmin 500");
			descrTextArea.setText(panels[ix][1]);
			layoutDisplayPanel.layout();
		} catch (Exception e1) {
			e1.printStackTrace();   // Should never happpen...
		}
	}

	public Control createTest(Composite parent2)
	{
//		TabFolder tabFolder = new TabFolder(parent2, DOUBLE_BUFFER);

		Composite parent = new Composite(parent2, SWT.NONE);

		MigLayout layout = new MigLayout("wrap 2");
		layout.setColumnConstraints("[grow, shrink][grow, shrink]");
		parent.setLayout(layout);

		Label label = new Label(parent, SWT.WRAP);
		label.setText("This is a long label");
		label.setLayoutData("width 20:pref:pref");

		label = new Label(parent, SWT.NONE);
		label.setText("Label 2");

		label = new Label(parent, SWT.NONE);
		label.setText("Label 3");

		label = new Label(parent, SWT.NONE);
		label.setText("Label 4");

		return parent;
	}

	public Control createWelcome(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		TabItem mainItem = createTabPanel(tabbedPane, "Welcome", new FillLayout());
		MigLayout lm = new MigLayout("ins 30, fill");
		Composite panel = createPanel(tabbedPane, lm);
		mainItem.setControl(panel);

		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" +
		           "The motto is: \"MigLayout makes complex layouts easy and normal layouts one-liners.\"\n\n" +
		           "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" +
		           "MigLayout can handle all layouts that the commonly used Swing Layout Managers can handle and this with a lot of extra features. " +
		           "It also incorporates most, if not all, of the open source alternatives FormLayout's and TableLayout's functionality." +
		           "\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." +
		           "\n\n\nMikael Grev\n" +
		           "MiG InfoCom AB\n" +
		           "miglayout@miginfocom.com";

		StyledText textArea = new StyledText(panel, SWT.MULTI | SWT.WRAP | SWT.BORDER);
		textArea.setText(s);
		textArea.setSize(400, 400);
		textArea.setLayoutData("w 500:500,ay top,grow");
		deriveFont(textArea, SWT.BOLD, -1);

		return tabbedPane;
	}

	public Composite createAPI_Constraints1(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		LC layC = new LC().fill().wrap();
		AC colC = new AC().align("right", 0).fill(1, 3).grow(100, 1, 3).align("right", 2).gap("15", 1);
		AC rowC = new AC().align("top", 7).gap("15!", 6).grow(100, 8);

		TabItem p1 = createTabPanel(tabbedPane, "Layout Showdown (improved)", new MigLayout(layC, colC, rowC));

		// References to text fields not stored to reduce code clutter.

		createList(p1, "Mouse, Mickey", new CC().dockWest().minWidth("150").gapX(null, "10"));
		createLabel(p1, "Last Name",    "");
		createTextField(p1, "",         "");
		createLabel(p1, "First Name",   "");
		createTextField(p1, "",         new CC().wrap());
		createLabel(p1, "Phone",        "");
		createTextField(p1, "",         "");
		createLabel(p1, "Email",        "");
		createTextField(p1, "",         "");
		createLabel(p1, "Address 1",    "");
		createTextField(p1,             "", new CC().spanX().growX());
		createLabel(p1, "Address 2",    "");
		createTextField(p1,             "", new CC().spanX().growX());
		createLabel(p1, "City",         "");
		createTextField(p1,             "", new CC().wrap());
		createLabel(p1, "State",        "");
		createTextField(p1, "",         "");
		createLabel(p1, "Postal Code",  "");
		createTextField(p1,             "", new CC().spanX(2).growX(0));
		createLabel(p1, "Country",      "");
		createTextField(p1, "",         new CC().wrap());

		createButton(p1, "New",         new CC().spanX(5).split(5).tag("other"));
		createButton(p1, "Delete",      new CC().tag("other"));
		createButton(p1, "Edit",        new CC().tag("other"));
		createButton(p1, "Save",        new CC().tag("other"));
		createButton(p1, "Cancel",      new CC().tag("cancel"));

		return tabbedPane;
	}

	public Composite createAPI_Constraints2(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		LC layC = new LC().fill().wrap();
		AC colC = new AC().align("right", 0).fill(1, 3).grow(100, 1, 3).align("right", 2).gap("15", 1);
		AC rowC = new AC().index(6).gap("15!").align("top").grow(100, 8);

		TabItem p1 = createTabPanel(tabbedPane, "Layout Showdown (improved)", new MigLayout(layC, colC, rowC));

		// References to text fields not stored to reduce code clutter.

		createLabel(p1, "Last Name",    "");
		createTextField(p1, "",         "");
		createLabel(p1, "First Name",   "");
		createTextField(p1, "",         new CC().wrap());
		createLabel(p1, "Phone",        "");
		createTextField(p1, "",         "");
		createLabel(p1, "Email",        "");
		createTextField(p1, "",         "");
		createLabel(p1, "Address 1",    "");
		createTextField(p1,             "", new CC().spanX().growX());
		createLabel(p1, "Address 2",    "");
		createTextField(p1,             "", new CC().spanX().growX());
		createLabel(p1, "City",         "");
		createTextField(p1,             "", new CC().wrap());
		createLabel(p1, "State",        "");
		createTextField(p1, "",         "");
		createLabel(p1, "Postal Code",  "");
		createTextField(p1,             "", new CC().spanX(2).growX(0));
		createLabel(p1, "Country",      "");
		createTextField(p1, "",         new CC().wrap());

		createButton(p1, "New",         new CC().spanX(5).split(5).tag("other"));
		createButton(p1, "Delete",      new CC().tag("other"));
		createButton(p1, "Edit",        new CC().tag("other"));
		createButton(p1, "Save",        new CC().tag("other"));
		createButton(p1, "Cancel",      new CC().tag("cancel"));

		return tabbedPane;
	}

	public Composite createLayout_Showdown(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		TabItem p1 = createTabPanel(tabbedPane, "Layout Showdown (pure)", new MigLayout("", "[]15[][grow,fill]15[grow]"));

		// References to text fields not stored to reduce code clutter.

		createList(p1, "Mouse, Mickey",   "spany, growy, wmin 150");
		createLabel(p1, "Last Name",      "");
		createTextField(p1, "",           "");
		createLabel(p1, "First Name",     "split");  // split divides the cell
		createTextField(p1, "",           "growx, wrap");
		createLabel(p1, "Phone",          "");
		createTextField(p1, "",           "");
		createLabel(p1, "Email",          "split");
		createTextField(p1, "",           "growx, wrap");
		createLabel(p1, "Address 1",      "");
		createTextField(p1, "",           "span, growx"); // span merges cells
		createLabel(p1, "Address 2",      "");
		createTextField(p1, "",           "span, growx");
		createLabel(p1, "City",           "");
		createTextField(p1, "",           "wrap"); // wrap continues on next line
		createLabel(p1, "State",          "");
		createTextField(p1, "",           "");
		createLabel(p1, "Postal Code",    "split");
		createTextField(p1, "",           "growx, wrap");
		createLabel(p1, "Country",        "");
		createTextField(p1, "",           "wrap 15");

		createButton(p1, "New",           "span, split, align right");
		createButton(p1, "Delete",        "");
		createButton(p1, "Edit",          "");
		createButton(p1, "Save",          "");
		createButton(p1, "Cancel",        "wrap push");


		// Fixed version *******************************************


		TabItem p2 = createTabPanel(tabbedPane, "Layout Showdown (improved)", new MigLayout("", "[]15[][grow,fill]15[][grow,fill]"));

		// References to text fields not stored to reduce code clutter.

		createList(p2, "Mouse, Mickey",   "spany, growy, wmin 150");
		createLabel(p2, "Last Name",      "");
		createTextField(p2, "",           "");
		createLabel(p2, "First Name",     "");
		createTextField(p2, "",           "wrap");
		createLabel(p2, "Phone",          "");
		createTextField(p2, "",           "");
		createLabel(p2, "Email",          "");
		createTextField(p2, "",           "wrap");
		createLabel(p2, "Address 1",      "");
		createTextField(p2, "",           "span");
		createLabel(p2, "Address 2",      "");
		createTextField(p2, "",           "span");
		createLabel(p2, "City",           "");
		createTextField(p2, "",           "wrap");
		createLabel(p2, "State",          "");
		createTextField(p2, "",           "");
		createLabel(p2, "Postal Code",    "");
		createTextField(p2, "",           "width 50, grow 0, wrap");
		createLabel(p2, "Country",        "");
		createTextField(p2, "",           "wrap 15");

		createButton(p2, "New",           "tag other, span, split");
		createButton(p2, "Delete",        "tag other");
		createButton(p2, "Edit",          "tag other");
		createButton(p2, "Save",          "tag other");
		createButton(p2, "Cancel",        "tag cancel, wrap push");

		return tabbedPane;
	}

	public Composite createDocking(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);
		tabbedPane.setLayoutData("grow");

		TabItem p1 = createTabPanel(tabbedPane, "Docking 1", new MigLayout("fill"));

		createPanel(p1, "1. North", "north");
		createPanel(p1, "2. West", "west");
		createPanel(p1, "3. East", "east");
		createPanel(p1, "4. South", "south");

		Table table = new Table(getComposite(p1), DOUBLE_BUFFER);
		for (int i = 0; i < 6; i++) {
			TableColumn tc = new TableColumn(table, SWT.LEFT | SWT.V_SCROLL | SWT.SCROLL_LINE);
			tc.setText("Column " + (i + 1));
			tc.setWidth(100);
		}

		for (int r = 0; r < 20; r++) {
			TableItem item1 = new TableItem(table,0);
			String[] data = new String[6];
			for (int c = 0; c < data.length; c++)
				data[c] = "Cell " + (r + 1) + ", " + (c + 1);
            item1.setText(data);
		}
		table.setHeaderVisible(true);
        table.setLinesVisible(true);
		table.setLayoutData("grow");


		TabItem p2 = createTabPanel(tabbedPane, "Docking 2 (fill)", new MigLayout("fill", "[c]", ""));

		createPanel(p2, "1. North", "north");
		createPanel(p2, "2. North", "north");
		createPanel(p2, "3. West", "west");
		createPanel(p2, "4. West", "west");
		createPanel(p2, "5. South", "south");
		createPanel(p2, "6. East", "east");
		createButton(p2, "7. Normal", "");
		createButton(p2, "8. Normal", "");
		createButton(p2, "9. Normal", "");

		TabItem p3 = createTabPanel(tabbedPane, "Docking 3", new MigLayout());

		createPanel(p3, "1. North", "north");
		createPanel(p3, "2. South", "south");
		createPanel(p3, "3. West", "west");
		createPanel(p3, "4. East", "east");
		createButton(p3, "5. Normal", "");

		TabItem p4 = createTabPanel(tabbedPane, "Docking 4", new MigLayout());

		createPanel(p4, "1. North", "north");
		createPanel(p4, "2. North", "north");
		createPanel(p4, "3. West", "west");
		createPanel(p4, "4. West", "west");
		createPanel(p4, "5. South", "south");
		createPanel(p4, "6. East", "east");
		createButton(p4, "7. Normal", "");
		createButton(p4, "8. Normal", "");
		createButton(p4, "9. Normal", "");

		TabItem p5 = createTabPanel(tabbedPane, "Docking 5 (fillx)", new MigLayout("fillx", "[c]", ""));

		createPanel(p5, "1. North", "north");
		createPanel(p5, "2. North", "north");
		createPanel(p5, "3. West", "west");
		createPanel(p5, "4. West", "west");
		createPanel(p5, "5. South", "south");
		createPanel(p5, "6. East", "east");
		createButton(p5, "7. Normal", "");
		createButton(p5, "8. Normal", "");
		createButton(p5, "9. Normal", "");

		TabItem p6 = createTabPanel(tabbedPane, "Random Docking", new MigLayout("fill"));

		String[] sides = {"north", "east", "south", "west"};
		Random rand = new Random();
		for (int i = 0; i < 20; i++) {
			int side = rand.nextInt(4);
			createPanel(p6, ((i + 1) + " " + sides[side]), sides[side]);
		}
		createPanel(p6, "I'm in the Center!", "grow");

		return tabbedPane;
	}

	public Control createAbsolute_Position(final Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// Pos tab
		TabItem posTabPanel = createTabPanel(tabbedPane, "X Y Positions", new FillLayout());
		final Composite posPanel = createPanel(posTabPanel, new MigLayout());

		createButton(posPanel, "pos 0.5al 0al", null);
		createButton(posPanel, "pos 1al 0al", null);
		createButton(posPanel, "pos 0.5al 0.5al", null);
		createButton(posPanel, "pos 5in 45lp", null);
		createButton(posPanel, "pos 0.5al 0.5al", null);
		createButton(posPanel, "pos 0.5al 1al", null);
		createButton(posPanel, "pos 1al .25al", null);
		createButton(posPanel, "pos visual.x2-pref visual.y2-pref", null);
		createButton(posPanel, "pos 1al -1in", null);
		createButton(posPanel, "pos 100 100", null);
		createButton(posPanel, "pos (10+(20*3lp)) 200", null);
		createButton(posPanel, "Drag Window! (pos 500-container.xpos 500-container.ypos)",
		             "pos 500-container.xpos 500-container.ypos");

		// Bounds tab
		TabItem boundsTabPanel = createTabPanel(tabbedPane, "X1 Y1 X2 Y2 Bounds", new FillLayout());
		Composite boundsPanel = createPanel(boundsTabPanel, new MigLayout());

		Label southLabel = createLabel(boundsPanel, "pos (visual.x+visual.w*0.1) visual.y2-40 (visual.x2-visual.w*0.1) visual.y2", null, SWT.CENTER | SWT.BORDER);
		southLabel.setBackground(new Color(display, 200, 200, 255));
		deriveFont(southLabel, SWT.BOLD, 10);

		createButton(boundsPanel, "pos 0 0 container.x2 n", null);
		createButton(boundsPanel, "pos visual.x 40 visual.x2 70", null);
		createButton(boundsPanel, "pos visual.x 100 visual.x2 p", null);
		createButton(boundsPanel, "pos 0.1al 0.4al n visual.y2-10", null);
		createButton(boundsPanel, "pos 0.9al 0.4al n visual.y2-10", null);
		createButton(boundsPanel, "pos 0.5al 0.5al, pad 3 0 -3 0", null);
		createButton(boundsPanel, "pos n n 50% 50%", null);
		createButton(boundsPanel, "pos 50% 50% n n", null);
		createButton(boundsPanel, "pos 50% n n 50%", null);
		createButton(boundsPanel, "pos n 50% 50% n", null);

		// Glass pane tab
//		final TabItem glassPanel = createTabPanel(tabbedPane, "GlassPane Substitute", parent, new SwtMigLayout("align c c"));
//		final Button butt = new Button("Press me!!");
//		glassPanel.add(butt);
//
//		butt.addActionListener(new ActionListener()		{
//			public void actionPerformed(ActionEvent e)
//			{
//				butt.setEnabled(false);
//				final JPanel bg = new JPanel(parent, new SwtMigLayout("align c c,fill")) {
//					public void paint(Graphics g)
//					{
//						g.setColor(getBackground());
//						g.fillRect(0, 0, getWidth(), getHeight());
//						super.paint(g);
//					}
//				};
//				bg.setOpaque(false);
//				configureActiveComponet(bg);
//
//				final Label label = createLabel("You don't need a GlassPane to be cool!");
//				label.setFont(label.getFont().deriveFont(30f));
//				label.setForeground(new Color(255, 255, 255, 0));
//				bg.add(label, "align 50% 30%");
//
//				glassPanel.add(bg, "pos 0 0 visual.x2 visual.y2", 0);
//				final long startTime = System.nanoTime();
//				final long endTime = startTime + 500000000L;
//
//				glassPanel.revalidate();
//
//				final javax.swing.Timer timer = new Timer(25, null);
//
//				timer.addActionListener(new ActionListener() {
//					public void actionPerformed(ActionEvent e)
//					{
//						long now = System.nanoTime();
//						int alpha = (int) (((now - startTime) / (double) (endTime - startTime)) * 300);
//						if (alpha < 150)
//							bg.setBackground(new Color(100, 100, 100, alpha));
//
//						if (alpha > 150 && alpha < 405) {
//							label.setForeground(new Color(255, 255, 255, (alpha - 150)));
//							bg.repaint();
//						}
//						if (alpha > 405)
//							timer.stop();
//					}
//				});
//				timer.start();
//			}
//		});
//

		parent.getShell().addControlListener(new ControlAdapter() {
			public void controlMoved(ControlEvent e)
			{
				if (!posPanel.isDisposed()) {
					posPanel.layout();
				} else {
					parent.getShell().removeControlListener(this);
				}
			}
		});

		return tabbedPane;
	}

	public Control createComponent_Links(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		TabItem linksPanel = createTabPanel(tabbedPane, "Component Links", new MigLayout());

		// Links tab
		createButton(linksPanel, "Mini", "pos null ta.y ta.x2 null, pad 3 0 -3 0");
		createTextArea(linksPanel, "Components, Please Link to Me!\nMy ID is: 'ta'", "id ta, pos 0.5al 0.5al, w 300");
		createButton(linksPanel, "id b1,pos ta.x2 ta.y2", null);
		createButton(linksPanel, "pos b1.x2+rel b1.y visual.x2 null", null);
		createCheck(linksPanel, "pos (ta.x+indent) (ta.y2+rel)", null);
		createButton(linksPanel, "pos ta.x2+rel ta.y visual.x2 null", null);
		createButton(linksPanel, "pos null ta.y+(ta.h-pref)/2 ta.x-rel null", null);
		createButton(linksPanel, "pos ta.x ta.y2+100 ta.x2 null", null);

		// External tab
		TabItem externalPanel = createTabPanel(tabbedPane, "External Components", new MigLayout());

		Button extButt = createButton(externalPanel, "Bounds Externally Set!", "id ext, external");
		extButt.setBounds(250, 130, 200, 40);
		createButton(externalPanel, "pos ext.x2 ext.y2", "pos ext.x2 ext.y2");
		createButton(externalPanel, "pos null null ext.x ext.y", "pos null null ext.x ext.y");

		TabItem egTabPanel = createTabPanel(tabbedPane, "End Grouping", new FillLayout());
		final Composite egPanel = createPanel(egTabPanel, new MigLayout());

		createButton(egPanel, "id b1, endgroupx g1, pos 200 200", null);
		createButton(egPanel, "id b2, endgroupx g1, pos (b1.x+2ind) (b1.y2+rel)", null);
		createButton(egPanel, "id b3, endgroupx g1, pos (b1.x+4ind) (b2.y2+rel)", null);
		createButton(egPanel, "id b4, endgroupx g1, pos (b1.x+6ind) (b3.y2+rel)", null);

		// Group Bounds tab
		TabItem gpTabPanel = createTabPanel(tabbedPane, "Group Bounds", new FillLayout());
		final Composite gpPanel = createPanel(gpTabPanel, new MigLayout());

		createButton(gpPanel, "id grp1.b1, pos n 0.5al 50% n", null);
		createButton(gpPanel, "id grp1.b2, pos 50% 0.5al n n", null);
		createButton(gpPanel, "id grp1.b3, pos 0.5al n n b1.y", null);
		createButton(gpPanel, "id grp1.b4, pos 0.5al b1.y2 n n", null);

		createButton(gpPanel, "pos n grp1.y2 grp1.x n", null);
		createButton(gpPanel, "pos n n grp1.x grp1.y", null);
		createButton(gpPanel, "pos grp1.x2 n n grp1.y", null);
		createButton(gpPanel, "pos grp1.x2 grp1.y2", null);

		Composite boundsPanel = createPanel(gpPanel, (Layout) null);
		boundsPanel.setLayoutData("pos grp1.x grp1.y grp1.x2 grp1.y2");
		boundsPanel.setBackground(new Color(display, 200, 200, 255));

		return tabbedPane;
	}

	public Control createFlow_Direction(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		createFlowPanel(tabbedPane, "Layout: flowx, Cell: flowx", "", "flowx");
		createFlowPanel(tabbedPane, "Layout: flowx, Cell: flowy", "", "flowy");
		createFlowPanel(tabbedPane, "Layout: flowy, Cell: flowx", "flowy", "flowx");
		createFlowPanel(tabbedPane, "Layout: flowy, Cell: flowy", "flowy", "flowy");

		return tabbedPane;
	}

	private TabItem createFlowPanel(TabFolder parent, String text, String gridFlow, String cellFlow)
	{
		MigLayout lm = new MigLayout("center, wrap 3," + gridFlow,
		                             "[110,fill]",
		                             "[110,fill]");
		TabItem panel = createTabPanel(parent, text, lm);

		for (int i = 0; i < 9; i++) {
			Composite b = createPanel(panel, "" + (i + 1), cellFlow);
			Font f = deriveFont(b, SWT.DEFAULT, 20);
			b.getChildren()[0].setFont(f);
		}

		Composite b = createPanel(panel, "5:2", cellFlow + ",cell 1 1");
		Font f = deriveFont(b, SWT.DEFAULT, 20);
		b.getChildren()[0].setFont(f);

		return panel;
	}

	public Control createDebug(Composite parent)
	{
		return createPlainImpl(parent, true);
	}

	public Control createButton_Bars(final Composite parent)
	{
		MigLayout lm = new MigLayout("ins 0 0 15lp 0",
		                                "[grow]",
		                                "[grow]u[baseline,nogrid]");

		final Composite mainPanel = new Composite(parent, DOUBLE_BUFFER);
		mainPanel.setLayout(lm);

		TabFolder tabbedPane = new TabFolder(mainPanel, DOUBLE_BUFFER);
		tabbedPane.setLayoutData("grow, wrap");

		createButtonBarsPanel(tabbedPane, "Buttons", "help", false);
		createButtonBarsPanel(tabbedPane, "Buttons with Help2", "help2", false);
		createButtonBarsPanel(tabbedPane, "Buttons (Same width)", "help", true);

		createLabel(mainPanel, "Button Order:", "");
		final Label formatLabel = createLabel(mainPanel, "", "growx");
		deriveFont(formatLabel, SWT.BOLD , -1);

		final Button winButt = createToggleButton(mainPanel, "Windows", "wmin button");
		final Button macButt = createToggleButton(mainPanel, "Mac OS X", "wmin button");

		winButt.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e)
			{
				if (winButt.getSelection()) {
					PlatformDefaults.setPlatform(PlatformDefaults.WINDOWS_XP);
					formatLabel.setText("'" + PlatformDefaults.getButtonOrder() + "'");
					macButt.setSelection(false);
					mainPanel.layout();
				}
			}
		});

		macButt.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e)
			{
				if (macButt.getSelection()) {
					PlatformDefaults.setPlatform(PlatformDefaults.MAC_OSX);
					formatLabel.setText("'" + PlatformDefaults.getButtonOrder() + "'");
					winButt.setSelection(false);
					mainPanel.layout();
				}
			}
		});

		Button helpButt = createButton(mainPanel, "Help", "gap unrel,wmin button");
		helpButt.addSelectionListener(new SelectionAdapter() {
			public void widgetSelected(SelectionEvent e)
			{
				MessageBox msgBox = new MessageBox(parent.getShell());
				msgBox.setMessage("See JavaDoc for PlatformConverter.getButtonBarOrder(..) for details on the format string.");
				msgBox.open();
			}
		});

		(PlatformDefaults.getPlatform() == PlatformDefaults.WINDOWS_XP ?  winButt : macButt).setSelection(true);

		return mainPanel;
	}

	private TabItem createButtonBarsPanel(TabFolder parent, String text, String helpTag, boolean sizeLocked)
	{
		MigLayout lm = new MigLayout("nogrid, fillx, aligny 100%, gapy unrel");
		TabItem panel = createTabPanel(parent, text, lm);

		// Notice that the order in the rows below does not matter...
		String[][] buttons = new String[][] {
				{"No", "Yes"},
				{"Help", "Close"},
				{"OK", "Help"},
				{"OK", "Cancel", "Help"},
				{"OK", "Cancel", "Apply", "Help"},
				{"No", "Yes", "Cancel"},
				{"Help", "< Move Back", "Move Forward >", "Cancel"},
				{"Print...", "Cancel", "Help"},
		};

		for (int r = 0; r < buttons.length; r++) {
			for (int i = 0; i < buttons[r].length; i++) {
				String txt = buttons[r][i];
				String tag = txt;

				if (txt.equals("Help")) {
					tag = helpTag;
				} else if (txt.equals("< Move Back")) {
					tag = "back";
				} else if (txt.equals("Close")) {
					tag = "cancel";
				} else if (txt.equals("Move Forward >")) {
					tag = "next";
				} else if (txt.equals("Print...")) {
					tag = "other";
				}
				String wrap = (i == buttons[r].length - 1) ? ",wrap" : "";
				String sizeGroup = sizeLocked ? ("sgx " + r + ",") : "";
				createButton(panel, txt, sizeGroup + "tag " + tag + wrap);
			}
		}

		return panel;
	}

	public Control createOrientation(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		MigLayout lm = new MigLayout("flowy", "[grow,fill]", "[]0[]15lp[]0[]");
		TabItem mainPanel = createTabPanel(tabbedPane, "Orientation", lm);

		// Default orientation
		MigLayout defLM = new MigLayout("", "[][grow,fill]", "");

		Composite defPanel = createPanel(mainPanel, defLM);
		addSeparator(defPanel, "Default Orientation");
		createLabel(defPanel, "Level", "");
		createTextField(defPanel, "", "span,growx");
		createLabel(defPanel, "Radar", "");
		createTextField(defPanel, "", "");
		createTextField(defPanel, "", "");

		// Right-to-left, Top-to-bottom
		MigLayout rtlLM = new MigLayout("rtl,ttb",
		                                   "[][grow,fill]",
		                                   "");
		Composite rtlPanel = createPanel(mainPanel, rtlLM);
		addSeparator(rtlPanel, "Right to Left");
		createLabel(rtlPanel, "Level", "");
		createTextField(rtlPanel, "", "span,growx");
		createLabel(rtlPanel, "Radar", "");
		createTextField(rtlPanel, "", "");
		createTextField(rtlPanel, "", "");

		// Right-to-left, Bottom-to-top
		MigLayout rtlbLM = new MigLayout("rtl,btt",
		                                 "[][grow,fill]",
		                                 "");
		Composite rtlbPanel = createPanel(mainPanel, rtlbLM);
		addSeparator(rtlbPanel, "Right to Left, Bottom to Top");
		createLabel(rtlbPanel, "Level", "");
		createTextField(rtlbPanel, "", "span,growx");
		createLabel(rtlbPanel, "Radar", "");
		createTextField(rtlbPanel, "", "");
		createTextField(rtlbPanel, "", "");

		// Left-to-right, Bottom-to-top
		MigLayout ltrbLM = new MigLayout("ltr,btt",
		                                 "[][grow,fill]",
		                                 "");

		Composite ltrbPanel = createPanel(mainPanel, ltrbLM);
		addSeparator(ltrbPanel, "Left to Right, Bottom to Top");
		createLabel(ltrbPanel, "Level", "");
		createTextField(ltrbPanel, "", "span,growx");
		createLabel(ltrbPanel, "Radar", "");
		createTextField(ltrbPanel, "", "");
		createTextField(ltrbPanel, "", "");

		return tabbedPane;
	}

	public Control createCell_Position(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// Absolute grid position
		MigLayout absLM = new MigLayout("",
		                                "[100:pref,fill]",
		                                "[100:pref,fill]");

		TabItem absPanel = createTabPanel(tabbedPane, "Absolute", absLM);
		createPanel(absPanel, "cell 0 0", null);
		createPanel(absPanel, "cell 2 0", null);
		createPanel(absPanel, "cell 3 0", null);
		createPanel(absPanel, "cell 1 1", null);
		createPanel(absPanel, "cell 0 2", null);
		createPanel(absPanel, "cell 2 2", null);
		createPanel(absPanel, "cell 2 2", null);


		// Relative grid position with wrap
		MigLayout relAwLM = new MigLayout("wrap",
		                                  "[100:pref,fill][100:pref,fill][100:pref,fill][100:pref,fill]",
		                                  "[100:pref,fill]");
		TabItem relAwPanel = createTabPanel(tabbedPane, "Relative + Wrap", relAwLM);
		createPanel(relAwPanel, "", null);
		createPanel(relAwPanel, "skip", null);
		createPanel(relAwPanel, "", null);
		createPanel(relAwPanel, "skip,wrap", null);
		createPanel(relAwPanel, "", null);
		createPanel(relAwPanel, "skip,split", null);
		createPanel(relAwPanel, "", null);


		// Relative grid position with manual wrap
		MigLayout relWLM = new MigLayout("",
		                                 "[100:pref,fill]",
		                                 "[100:pref,fill]");
		TabItem relWPanel = createTabPanel(tabbedPane, "Relative", relWLM);
		createPanel(relWPanel, "", null);
		createPanel(relWPanel, "skip", null);
		createPanel(relWPanel, "wrap", null);
		createPanel(relWPanel, "skip,wrap", null);
		createPanel(relWPanel, "", null);
		createPanel(relWPanel, "skip,split", null);
		createPanel(relWPanel, "", null);


		// Mixed relative and absolute grid position
		MigLayout mixLM = new MigLayout("",
		                                   "[100:pref,fill]",
		                                   "[100:pref,fill]");
		TabItem mixPanel = createTabPanel(tabbedPane, "Mixed", mixLM);
		createPanel(mixPanel, "", null);
		createPanel(mixPanel, "cell 2 0", null);
		createPanel(mixPanel, "", null);
		createPanel(mixPanel, "cell 1 1,wrap", null);
		createPanel(mixPanel, "", null);
		createPanel(mixPanel, "cell 2 2,split", null);
		createPanel(mixPanel, "", null);

		return tabbedPane;
	}

	public Control createPlain(Composite parent)
	{
		return createPlainImpl(parent, false);
	}

	private Control createPlainImpl(Composite parent, boolean debug)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		MigLayout lm = new MigLayout((debug && benchRuns == 0 ? "debug" : ""), "[r][100lp, fill][60lp][95lp, fill]", "");
		TabItem panel = createTabPanel(tabbedPane, "Plain", lm);

		addSeparator(panel, "Manufacturer");
		createLabel(panel, "Company", "");
		createTextField(panel, "", "span,growx");
		createLabel(panel, "Contact", "");
		createTextField(panel, "", "span,growx");
		createLabel(panel, "Order No", "");
		createTextField(panel, "", "wmin 15*6,wrap");

		addSeparator(panel, "Inspector");
		createLabel(panel, "Name", "");
		createTextField(panel, "", "span,growx");
		createLabel(panel, "Reference No", "");
		createTextField(panel, "", "wrap");
		createLabel(panel, "Status", "");
		createCombo(panel, new String[] {"In Progress", "Finnished", "Released"}, "wrap");

		addSeparator(panel, "Ship");
		createLabel(panel, "Shipyard", "");
		createTextField(panel, "", "span,growx");
		createLabel(panel, "Register No", "");
		createTextField(panel, "", "");
		createLabel(panel, "Hull No", "right");
		createTextField(panel, "", "wmin 15*6,wrap");
		createLabel(panel, "Project Type", "");
		createCombo(panel, new String[] {"New Building", "Convention", "Repair"}, "wrap");

		if (debug)
			createLabel(panel, "Blue is component bounds. Cell bounds (red) can not be shown in SWT", "newline,ax left,span,gaptop 40");

		return tabbedPane;
	}

	public Control createBound_Sizes(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		for (int i = 0; i < 2; i++) {   // Jumping for 0 and Stable for 1
			String colConstr = i == 0 ? "[right][200]" : "[right, 75lp:pref][200]";

			MigLayout LM1 = new MigLayout("wrap", colConstr, "");
			TabItem panel1 = createTabPanel(tabbedPane, i == 0 ? "Jumping 1" : "Stable 2", LM1);
			createLabel(panel1, "File Number:", "");
			createTextField(panel1, "", "growx");
			createLabel(panel1, "RFQ Number:", "");
			createTextField(panel1, "", "growx");
			createLabel(panel1, "Entry Date:", "");
			createTextField(panel1, "", "wmin 6*6");
			createLabel(panel1, "Sales Person:", "");
			createTextField(panel1, "", "growx");

			MigLayout LM2 = new MigLayout("wrap", colConstr, "");
			TabItem panel2 = createTabPanel(tabbedPane, i == 0 ? "Jumping 2" : "Stable 2", LM2);
			createLabel(panel2, "Shipper:", "");
			createTextField(panel2, "", "wmin 6*6,split 2");
			createTextField(panel2, "", "growx");
			createLabel(panel2, "Consignee:", "");
			createTextField(panel2, "", "wmin 6*6,split 2");
			createTextField(panel2, "", "growx");
			createLabel(panel2, "Departure:", "");
			createTextField(panel2, "", "wmin 6*6,split 2");
			createTextField(panel2, "", "growx");
			createLabel(panel2, "Destination:", "");
			createTextField(panel2, "", "wmin 6*6,split 2");
			createTextField(panel2, "", "growx");
		}
		return tabbedPane;
	}

	public Control createComponent_Sizes(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		MigLayout lm = new MigLayout("wrap", "[right][0:pref,grow]", "");

		TabItem tabPanel = createTabPanel(tabbedPane, "Component Sizes", new FillLayout());

		SashForm sashForm = new SashForm(getComposite(tabPanel), SWT.HORIZONTAL | SWT.SMOOTH);
		sashForm.setBackground(new Color(display, 50, 50, 50));

		Composite panel = createPanel(sashForm, lm);
		createTextArea(sashForm, "Use slider to see how the components grow and shrink depending on the constraints set on them.", "");

		createLabel(panel, "", "");
		createTextField(panel, "8       ", "");
		createLabel(panel, "width min!", null);
		createTextField(panel, "3  ", "width min!");
		createLabel(panel, "width pref!", "");
		createTextField(panel, "3  ", "width pref!");
		createLabel(panel, "width min:pref", null);
		createTextField(panel, "8       ", "width min:pref");
		createLabel(panel, "width min:100:150", null);
		createTextField(panel, "8       ", "width min:100:150");
		createLabel(panel, "width min:100:150, growx", null);
		createTextField(panel, "8       ", "width min:100:150, growx");
		createLabel(panel, "width min:100, growx", null);
		createTextField(panel, "8       ", "width min:100, growx");
		createLabel(panel, "width 40!", null);
		createTextField(panel, "8       ", "width 40!");
		createLabel(panel, "width 40:40:40", null);
		createTextField(panel, "8       ", "width 40:40:40");

		return tabbedPane;
	}

	public Control createCell_Alignments(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// Horizontal
		MigLayout hLM = new MigLayout("wrap",
		                              "[grow,left][grow,center][grow,right][grow,fill,center]",
		                              "[]unrel[][]");
		TabItem hPanel = createTabPanel(tabbedPane, "Horizontal", hLM);
		String[] sizes = new String[] {"", "growx", "growx 0", "left", "center", "right", "leading", "trailing"};
		createLabel(hPanel, "[left]", "c");
		createLabel(hPanel, "[center]", "c");
		createLabel(hPanel, "[right]", "c");
		createLabel(hPanel, "[fill,center]", "c, growx 0");

		for (int r = 0; r < sizes.length; r++) {
			for (int c = 0; c < 4; c++) {
				String text = sizes[r].length() > 0 ? sizes[r] : "default";
				createButton(hPanel, text, sizes[r]);
			}
		}

		// Vertical
		MigLayout vLM = new MigLayout("wrap,flowy",
		                                 "[right][]",
		                                 "[grow,top][grow,center][grow,bottom][grow,fill,bottom][grow,fill,baseline]");
		TabItem vPanel = createTabPanel(tabbedPane, "Vertical", vLM);
		String[] vSizes = new String[] {"", "growy", "growy 0", "top", "center", "bottom"};
		createLabel(vPanel, "[top]", "center");
		createLabel(vPanel, "[center]", "center");
		createLabel(vPanel, "[bottom]", "center");
		createLabel(vPanel, "[fill, bottom]", "center, growy 0");
		createLabel(vPanel, "[fill, baseline]", "center");

		for (int c = 0; c < vSizes.length; c++) {
			for (int r = 0; r < 5; r++) {
				String text = vSizes[c].length() > 0 ? vSizes[c] : "default";
				createButton(vPanel, text, vSizes[c]);
			}
		}

		return tabbedPane;
	}

	public Control createUnits(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// Horizontal
		MigLayout hLM = new MigLayout("wrap",
		                              "[right][]",
		                              "");
		TabItem hPanel = createTabPanel(tabbedPane, "Horizontal", hLM);
		String[] sizes = new String[] {"72pt", "25.4mm", "2.54cm", "1in", "72px", "96px", "120px", "25%", "30sp"};
		for (int i = 0; i < sizes.length; i++) {
			createLabel(hPanel, sizes[i], "");
			createTextField(hPanel, "", "width " + sizes[i] + "");
		}

		// Horizontal lp
		MigLayout hlpLM = new MigLayout("", "[right][][]", "");
		TabItem hlpPanel = createTabPanel(tabbedPane, "Horizontal LP", hlpLM);
		createLabel(hlpPanel, "9 cols", "");
		createTextField(hlpPanel, "", "wmin 9*6");
		String[] lpSizes = new String[] {"75lp", "75px", "88px", "100px"};
		createLabel(hlpPanel, "", "wrap");
		for (int i = 0; i < lpSizes.length; i++) {
			createLabel(hlpPanel, lpSizes[i], "");
			createTextField(hlpPanel, "", "width " + lpSizes[i] + ", wrap");
		}

		// Vertical
		MigLayout vLM = new MigLayout("wrap,flowy",
		                                 "[c]",
		                                 "[top][top]");
		TabItem vPanel = createTabPanel(tabbedPane, "Vertical", vLM);
		String[] vSizes = new String[] {"72pt", "25.4mm", "2.54cm", "1in", "72px", "96px", "120px", "25%", "30sp"};
		for (int i = 0; i < sizes.length; i++) {
			createLabel(vPanel, vSizes[i], "");
			createTextArea(vPanel, "", "width 50!, height " + vSizes[i] + "");
		}

		// Vertical lp
		MigLayout vlpLM = new MigLayout("wrap,flowy",
		                                   "[c]",
		                                   "[top][top]40px[top][top]");
		TabItem vlpPanel = createTabPanel(tabbedPane, "Vertical LP", vlpLM);
		createLabel(vlpPanel, "4 rows", "");
		createTextArea(vlpPanel, "\n\n\n\n", "width 50!");
		createLabel(vlpPanel, "field", "");
		createTextField(vlpPanel, "", "wmin 5*9");

		String[] vlpSizes1 = new String[] {"63lp", "57px", "63px", "68px", "25%"};
		String[] vlpSizes2 = new String[] {"21lp", "21px", "23px", "24px", "10%"};
		for (int i = 0; i < vlpSizes1.length; i++) {
			createLabel(vlpPanel, vlpSizes1[i], "");
			createTextArea(vlpPanel, "", "width 50!, height " + vlpSizes1[i] + "");
			createLabel(vlpPanel, vlpSizes2[i], "");
			createTextField(vlpPanel, "", "height " + vlpSizes2[i] + "!,wmin 5*6");
		}

		createLabel(vlpPanel, "button", "skip 2");
		createButton(vlpPanel, "...", "");

		return tabbedPane;
	}

	public Control createGrouping(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// Ungrouped
		MigLayout ugM = new MigLayout("", "[]push[][][]", "");
		TabItem ugPanel = createTabPanel(tabbedPane, "Ungrouped", ugM);
		createButton(ugPanel, "Help", "");
		createButton(ugPanel, "< Back", "gap push");
		createButton(ugPanel, "Forward >", "");
		createButton(ugPanel, "Apply", "gap unrel");
		createButton(ugPanel, "Cancel", "gap unrel");

		// Grouped Components
		MigLayout gM = new MigLayout("nogrid, fillx");
		TabItem gPanel = createTabPanel(tabbedPane, "Grouped (Components)", gM);
		createButton(gPanel, "Help", "sg");
		createButton(gPanel, "< Back", "sg, gap push");
		createButton(gPanel, "Forward >", "sg");
		createButton(gPanel, "Apply", "sg, gap unrel");
		createButton(gPanel, "Cancel", "sg, gap unrel");

		// Grouped Columns
		MigLayout gcM = new MigLayout("", "[sg,fill]push[sg,fill][sg,fill]unrel[sg,fill]unrel[sg,fill]", "");
		TabItem gcPanel = createTabPanel(tabbedPane, "Grouped (Columns)", gcM);
		createButton(gcPanel, "Help", "");
		createButton(gcPanel, "< Back", "");
		createButton(gcPanel, "Forward >", "");
		createButton(gcPanel, "Apply", "");
		createButton(gcPanel, "Cancel", "");

		// Ungrouped Rows
		MigLayout ugrM = new MigLayout();     // no "sg" is the only difference to next panel
		TabItem ugrPanel = createTabPanel(tabbedPane, "Ungrouped Rows", ugrM);
		createLabel(ugrPanel, "File Number:", "");
		createTextField(ugrPanel, "30                            ", "wrap");
		createLabel(ugrPanel, "BL/MBL number:", "");
		createTextField(ugrPanel, "7      ", "split 2");
		createTextField(ugrPanel, "7      ", "wrap");
		createLabel(ugrPanel, "Entry Date:", "");
		createTextField(ugrPanel, "7      ", "wrap");
		createLabel(ugrPanel, "RFQ Number:", "");
		createTextField(ugrPanel, "30                            ", "wrap");
		createLabel(ugrPanel, "Goods:", "");
		createCheck(ugrPanel, "Dangerous", "wrap");
		createLabel(ugrPanel, "Shipper:", "");
		createTextField(ugrPanel, "30                            ", "wrap");
		createLabel(ugrPanel, "Customer:", "");
		createTextField(ugrPanel, "", "split 2,growx");
		createButton(ugrPanel, "...", "width 60px:pref,wrap");
		createLabel(ugrPanel, "Port of Loading:", "");
		createTextField(ugrPanel, "30                            ", "wrap");
		createLabel(ugrPanel, "Destination:", "");
		createTextField(ugrPanel, "30                            ", "wrap");

		// Grouped Rows
		MigLayout grM = new MigLayout("", "[]", "[sg]");    // "sg" is the only difference to previous panel
		TabItem grPanel = createTabPanel(tabbedPane, "Grouped Rows", grM);
		createLabel(grPanel, "File Number:", "");
		createTextField(grPanel, "30                            ","wrap");
		createLabel(grPanel, "BL/MBL number:", "");
		createTextField(grPanel, "7      ","split 2");
		createTextField(grPanel, "7      ", "wrap");
		createLabel(grPanel, "Entry Date:", "");
		createTextField(grPanel, "7      ", "wrap");
		createLabel(grPanel, "RFQ Number:", "");
		createTextField(grPanel, "30                            ", "wrap");
		createLabel(grPanel, "Goods:", "");
		createCheck(grPanel, "Dangerous", "wrap");
		createLabel(grPanel, "Shipper:", "");
		createTextField(grPanel, "30                            ", "wrap");
		createLabel(grPanel, "Customer:", "");
		createTextField(grPanel, "", "split 2,growx");
		createButton(grPanel, "...", "width 50px:pref,wrap");
		createLabel(grPanel, "Port of Loading:", "");
		createTextField(grPanel, "30                            ", "wrap");
		createLabel(grPanel, "Destination:", "");
		createTextField(grPanel, "30                            ", "wrap");

		return tabbedPane;
	}

	public Control createSpan(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// Horizontal span
		MigLayout colLM = new MigLayout("",
		                                "[fill][25%,fill][105lp!,fill][150px!,fill]",
		                                "[]15[][]");
		TabItem colPanel = createTabPanel(tabbedPane, "Column Span/Split", colLM);
		createTextField(colPanel, "Col1 [ ]", "");
		createTextField(colPanel, "Col2 [25%]", "");
		createTextField(colPanel, "Col3 [105lp!]", "");
		createTextField(colPanel, "Col4 [150px!]", "wrap");

		createLabel(colPanel, "Full Name:", "");
		createTextField(colPanel, "span, growx                              ", "span,growx");

		createLabel(colPanel, "Phone:", "");
		createTextField(colPanel, "   ", "span 3, split 5");
		createTextField(colPanel, "     ", null);
		createTextField(colPanel, "     ", null);
		createTextField(colPanel, "       ", null);
		createLabel(colPanel, "(span 3, split 4)", "wrap");

		createLabel(colPanel, "Zip/City:", "");
		createTextField(colPanel, "     ", "");
		createTextField(colPanel, "span 2, growx", null);

		// Vertical span
		MigLayout rowLM = new MigLayout("wrap",
		                                   "[225lp]para[225lp]",
		                                   "[]3[]unrel[]3[]unrel[]3[]");
		TabItem rowPanel = createTabPanel(tabbedPane, "Row Span", rowLM);
		createLabel(rowPanel, "Name", "");
		createLabel(rowPanel, "Notes", "");
		createTextField(rowPanel, "growx", null);
		createTextArea(rowPanel, "spany,grow          ", "spany,grow,hmin 13*5");
		createLabel(rowPanel, "Phone", "");
		createTextField(rowPanel, "growx", null);
		createLabel(rowPanel, "Fax", "");
		createTextField(rowPanel, "growx", null);


		return tabbedPane;
	}

	public Control createGrowing(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// All tab
		MigLayout allLM = new MigLayout("",
		                                "[pref!][grow,fill]",
		                                "[]15[]");
		TabItem allTab = createTabPanel(tabbedPane, "All", allLM);
		createLabel(allTab, "Fixed", "");
		createLabel(allTab, "Gets all extra space", "wrap");
		createTextField(allTab, "     ", "");
		createTextField(allTab, "     ", "");

		// Half tab
		MigLayout halfLM = new MigLayout("",
		                                 "[pref!][grow,fill]",
		                                 "[]15[]");
		TabItem halfTab = createTabPanel(tabbedPane, "Half", halfLM);
		createLabel(halfTab, "Fixed", "");
		createLabel(halfTab, "Gets half of extra space", "");
		createLabel(halfTab, "Gets half of extra space", "wrap");
		createTextField(halfTab, "     ", "");
		createTextField(halfTab, "     ", "");
		createTextField(halfTab, "     ", "");

		// Percent 1 tab
		MigLayout p1LM = new MigLayout("",
		                                  "[pref!][0:0,grow 25,fill][0:0,grow 75,fill]",
		                                  "[]15[]");
		TabItem p1Tab = createTabPanel(tabbedPane, "Percent 1", p1LM);
		createLabel(p1Tab, "Fixed", "");
		createLabel(p1Tab, "Gets 25% of extra space", "");
		createLabel(p1Tab, "Gets 75% of extra space", "wrap");
		createTextField(p1Tab, "     ", "");
		createTextField(p1Tab, "     ", "");
		createTextField(p1Tab, "     ", "");

		// Percent 2 tab
		MigLayout p2LM = new MigLayout("",
		                                  "[0:0,grow 33,fill][0:0,grow 67,fill]",
		                                  "[]15[]");
		TabItem p2Tab = createTabPanel(tabbedPane, "Percent 2", p2LM);
		createLabel(p2Tab, "Gets 33% of extra space", "");
		createLabel(p2Tab, "Gets 67% of extra space", "wrap");
		createTextField(p2Tab, "     ", "");
		createTextField(p2Tab, "     ", "");

		// Vertical 1 tab
		MigLayout v1LM = new MigLayout("flowy",
		                               "[]15[]",
		                               "[][c,pref!][c,grow 25,fill][c,grow 75,fill]");
		TabItem v1Tab = createTabPanel(tabbedPane, "Vertical 1", v1LM);
		createLabel(v1Tab, "Fixed", "skip");
		createLabel(v1Tab, "Gets 25% of extra space", "");
		createLabel(v1Tab, "Gets 75% of extra space", "wrap");
		createLabel(v1Tab, "new Text(SWT.MULTI | SWT.WRAP | SWT.BORDER)", "");
		createTextArea(v1Tab, "", "hmin 4*13");
		createTextArea(v1Tab, "", "hmin 4*13");
		createTextArea(v1Tab, "", "hmin 4*13");

		// Vertical 2 tab
		MigLayout v2LM = new MigLayout("flowy",
		                                  "[]15[]",
		                                  "[][c,grow 33,fill][c,grow 67,fill]");
		TabItem v2Tab = createTabPanel(tabbedPane, "Vertical 2", v2LM);
		createLabel(v2Tab, "Gets 33% of extra space", "skip");
		createLabel(v2Tab, "Gets 67% of extra space", "wrap");
		createLabel(v2Tab, "new Text(SWT.MULTI | SWT.WRAP | SWT.BORDER)", "");
		createTextArea(v2Tab, "", "hmin 4*13");
		createTextArea(v2Tab, "", "hmin 4*13");

		return tabbedPane;
	}

	public Control createBasic_Sizes(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// Horizontal tab
		MigLayout horLM = new MigLayout("",
		                                "[]15[75px]25[min]25[]",
		                                "[]15");
		TabItem horTab = createTabPanel(tabbedPane, "Horizontal - Column size set", horLM);
		createLabel(horTab, "75px", "skip");
		createLabel(horTab, "Min", "");
		createLabel(horTab, "Pref", "wrap");

		createLabel(horTab, "new Text(15)", "");
		createTextField(horTab, "", "wmin 10");
		createTextField(horTab, "", "wmin 10");
		createTextField(horTab, "", "wmin 10");

		// Vertical tab 1
		MigLayout verLM = new MigLayout("flowy,wrap",
		                                   "[]15[]",
		                                   "[]15[c,45:45]15[c,min]15[c,pref]");
		TabItem verTab = createTabPanel(tabbedPane, "\"Vertical - Row sized\"", verLM);
		createLabel(verTab, "45px", "skip");
		createLabel(verTab, "Min", "");
		createLabel(verTab, "Pref", "");

		createLabel(verTab, "new Text(SWT.MULTI)", "");
		createTextArea(verTab, "", "");
		createTextArea(verTab, "", "");
		createTextArea(verTab, "", "");

		// Componentsized/Baseline 2
		MigLayout verLM2 = new MigLayout("flowy,wrap",
		                                    "[]15[]",
		                                    "[]15[baseline]15[baseline]15[baseline]");
		TabItem verTab2 = createTabPanel(tabbedPane, "\"Vertical - Component sized + Baseline\"", verLM2);
		createLabel(verTab2, "45px", "skip");
		createLabel(verTab2, "Min", "");
		createLabel(verTab2, "Pref", "");

		createLabel(verTab2, "new Text(SWT.MULTI)", "");
		createTextArea(verTab2, "", "height 45");
		createTextArea(verTab2, "", "height min");
		createTextArea(verTab2, "", "height pref");

		return tabbedPane;
	}

	public Control createAlignments(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// Horizontal tab
		MigLayout horLM = new MigLayout("wrap",
		                                "[label]15[left]15[center]15[right]15[fill]15[]",
		                                "[]15[]");

		String[] horLabels = new String[] {"[label]", "[left]", "[center]", "[right]", "[fill]", "[] (Default)"};
		TabItem horTab = createTabPanel(tabbedPane, "Horizontal", horLM);
		String[] horNames = new String[] {"First Name", "Phone Number", "Facsmile", "Email", "Address", "Other"};
		for (int c = 0; c < horLabels.length; c++)
			createLabel(horTab, horLabels[c], "");

		for (int r = 0; r < horLabels.length; r++) {
			for (int c = 0; c < horNames.length; c++) {
				if (c == 0) {
					createLabel(horTab, horNames[r] + ":", "");
				} else {
					createButton(horTab, horNames[r], "");
				}
			}
		}

		// Vertical tab
		MigLayout verLM = new MigLayout("wrap,flowy",
		                                "[]unrel[]rel[]",
		                                "[top]15[center]15[bottom]15[fill]15[fill,baseline]15[baseline]15[]");

		String[] verLabels = new String[] {"[top]", "[center]", "[bottom]", "[fill]", "[fill,baseline]", "[baseline]", "[] (Default)"};
		TabItem verTab = createTabPanel(tabbedPane, "Vertical", verLM);

		for (int c = 0; c < verLabels.length; c++)
			createLabel(verTab, verLabels[c], "");

		for (int c = 0; c < verLabels.length; c++)
			createButton(verTab, "A Button", "");

		for (int c = 0; c < verLabels.length; c++)
			createTextField(verTab, "JTextFied", "");

		for (int c = 0; c < verLabels.length; c++)
			createTextArea(verTab, "Text    ", "");

		for (int c = 0; c < verLabels.length; c++)
			createTextArea(verTab, "Text\nwith two lines", "");

		for (int c = 0; c < verLabels.length; c++)
			createTextArea(verTab, "Scrolling Text\nwith two lines", "");

		return tabbedPane;
	}

	public Control createQuick_Start(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		MigLayout lm = new MigLayout("wrap",
		                             "[right][fill,sizegroup]unrel[right][fill,sizegroup]",
		                             "");

		TabItem p = createTabPanel(tabbedPane, "Quick Start", lm);

		addSeparator(p, "General");
		createLabel(p, "Company", "gap indent");
		createTextField(p, "", "span,growx");
		createLabel(p, "Contact", "gap indent");
		createTextField(p, "", "span,growx");

		addSeparator(p, "Propeller");
		createLabel(p, "PTI/kW", "gap indent");
		createTextField(p, "", "wmin 100");
		createLabel(p, "Power/kW", "gap indent");
		createTextField(p, "", "wmin 100");
		createLabel(p, "R/mm", "gap indent");
		createTextField(p, "", "wmin 100");
		createLabel(p, "D/mm", "gap indent");
		createTextField(p, "", "wmin 100");

		return tabbedPane;
	}

	public Control createGrow_Shrink(Composite parent)
	{
		TabFolder tabbedPane = new TabFolder(parent, DOUBLE_BUFFER);

		// shrink tab
		MigLayout slm = new MigLayout("nogrid");
		TabItem shrinkTabPanel = createTabPanel(tabbedPane, "Shrink", new FillLayout());


		SashForm shrinkSash = new SashForm(getComposite(shrinkTabPanel), SWT.HORIZONTAL | SWT.SMOOTH);
		shrinkSash.setBackground(new Color(display, 100, 100, 100));

		Composite shrinkPanel = createPanel(shrinkSash, slm);
		shrinkPanel.setLayoutData("wmin 100");

		createTextField(shrinkPanel, "shp 110", "shp 110,w 10:130");
		createTextField(shrinkPanel, "Default (100)", "w 10:130");
		createTextField(shrinkPanel, "shp 90", "shp 90,w 10:130");

		createTextField(shrinkPanel, "shrink 25", "newline,shrink 25,w 10:130");
		createTextField(shrinkPanel, "shrink 75", "shrink 75,w 10:130");

		createTextField(shrinkPanel, "Default", "newline, w 10:130");
		createTextField(shrinkPanel, "Default", "w 10:130");

		createTextField(shrinkPanel, "shrink 0", "newline,shrink 0,w 10:130");

		createTextField(shrinkPanel, "shp 110",  "newline,shp 110,w 10:130");
		createTextField(shrinkPanel, "shp 100,shrink 25", "shp 100,shrink 25,w 10:130");
		createTextField(shrinkPanel, "shp 100,shrink 75", "shp 100,shrink 75,w 10:130");

		createTextArea(shrinkSash, "Use the slider to see how the components shrink depending on the constraints set on them.\n\n'shp' means Shrink Priority. " +
		                           "Lower values will be shrunk before higer ones and the default value is 100.\n\n'shrink' means Shrink Weight. " +
		                           "Lower values relative to other's means they will shrink less when space is scarse. " +
		                           "Shrink Weight is only relative to components with the same Shrink Priority. Default Shrink Weight is 100.\n\n" +
		                           "The component's minimum size will always be honored.\n\nFor SWT, which doesn't have a component notion of minimum, " +
		                           "preferred or maximum size, those sizes are set explicitly to minimum 10 and preferred 130 pixels.", "");

		// Grow tab
		TabItem growTabPanel = createTabPanel(tabbedPane, "Grow", new FillLayout());

		SashForm growSash = new SashForm(getComposite(growTabPanel), SWT.HORIZONTAL | SWT.SMOOTH);
		growSash.setBackground(new Color(display, 100, 100, 100));

		Composite growPanel = createPanel(growSash, new MigLayout("nogrid", "[grow]"));
		growPanel.setLayoutData("wmin 100");

		createButton(growPanel, "gp 110, grow", "gp 110, grow, wmax 170");
		createButton(growPanel, "Default (100), grow", "grow, wmax 170");
		createButton(growPanel, "gp 90, grow", "gp 90, grow, wmax 170");

		createButton(growPanel, "Default Button", "newline");

		createButton(growPanel, "growx", "newline,growx,wrap");

		createButton(growPanel, "gp 110, grow", "gp 110, grow, wmax 170");
		createButton(growPanel, "gp 100, grow 25", "gp 100, grow 25, wmax 170");
		createButton(growPanel, "gp 100, grow 75", "gp 100, grow 75, wmax 170");

		createTextArea(growSash, "'gp' means Grow Priority. " +
		                         "Lower values will be grown before higher ones and the default value is 100.\n\n'grow' means Grow Weight. " +
		                         "Higher values relative to other's means they will grow more when space is up for takes. " +
		                         "Grow Weight is only relative to components with the same Grow Priority. Default Grow Weight is 0 which means " +
		                         "components will normally not grow. \n\nNote that the buttons in the first and last row have max width set to 170 to " +
		                         "emphasize Grow Priority.\n\nThe component's maximum size will always be honored.", "");

		return tabbedPane;
	}


	// **********************************************************
	// * Helper Methods
	// **********************************************************

//	private final ToolTipListener toolTipListener = new ToolTipListener();
//	private final ConstraintListener constraintListener = new ConstraintListener();

	private Combo createCombo(Object parent, String[] texts, Object layout)
	{
		Combo b = new Combo(getComposite(parent), SWT.DROP_DOWN);
		for (int i = 0; i < texts.length; i++)
			b.add(texts[i]);
		b.setLayoutData(layout);

//		configureActiveComponet(b);

		return b;
	}

	private Label createLabel(Object parent, String text, Object layout)
	{
		return createLabel(parent, text, layout, SWT.LEFT);
	}

	private Label createLabel(Object parent, String text, Object layout, int style)
	{
		final Label b = new Label(getComposite(parent), style | DOUBLE_BUFFER);
		b.setText(text);
		b.setLayoutData(layout != null ? layout : text);
//		b.setAlignment();

//		configureActiveComponet(b);

		return b;
	}

	private Text createTextField(Object parent, String text, Object layout)
	{
		final Text b = new Text(getComposite(parent), SWT.SINGLE | SWT.BORDER | DOUBLE_BUFFER);
		b.setText(text);
		b.setLayoutData(layout != null ? layout : text);

//		configureActiveComponet(b);

		return b;
	}

	private Button createButton(Object parent, String text, Object layout)
	{
		return createButton(getComposite(parent), text, layout, false);
	}

	private Button createButton(Object parent, String text, Object layout, boolean bold)
	{
		Button b = new Button(getComposite(parent), SWT.PUSH | SWT.NO_BACKGROUND | DOUBLE_BUFFER);
		b.setText(text.length() == 0 ? "\"\"" : text);
		b.setLayoutData(layout != null ? layout : text);

//		configureActiveComponet(b);

		return b;
	}

	private Composite createPanel(Object parent, String text, Object layout)
	{
		Color bg = new Color(display.getActiveShell().getDisplay(), 255, 255, 255);
		Composite panel = new Composite(getComposite(parent), DOUBLE_BUFFER | SWT.BORDER);
		panel.setLayout(new MigLayout("fill"));
		panel.setBackground(bg);
		panel.setLayoutData(layout != null ? layout : text);
		text = text.length() == 0 ? "\"\"" : text;
		Label label = createLabel(panel, text, "grow", SWT.NO_BACKGROUND | SWT.CENTER);
		label.setBackground(bg);

//		configureActiveComponet(panel);

		return panel;
	}

	private TabItem createTabPanel(TabFolder parent, String text, Layout lm)
	{
		Composite panel = new Composite(parent, DOUBLE_BUFFER);
//		panel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
		TabItem tab = new TabItem(parent, DOUBLE_BUFFER);
		tab.setControl(panel);
		tab.setText(text);
		if (lm != null)
			panel.setLayout(lm);

//		configureActiveComponet(panel);
		return tab;
	}

	private Composite createPanel(Object parent, Layout lm)
	{
		Composite panel = new Composite(getComposite(parent), DOUBLE_BUFFER);
		panel.setLayout(lm);

//		configureActiveComponet(panel);

		return panel;
	}

	private Button createToggleButton(Object parent, String text, Object layout)
	{
		Button b = new Button(getComposite(parent), SWT.TOGGLE | DOUBLE_BUFFER);
		b.setText(text.length() == 0 ? "\"\"" : text);
		b.setLayoutData(layout != null ? layout : text);

//		configureActiveComponet(b);

		return b;
	}

	private Button createCheck(Object parent, String text, Object layout)
	{
		Button b = new Button(getComposite(parent), SWT.CHECK | DOUBLE_BUFFER);
		b.setText(text);
		b.setLayoutData(layout != null ? layout : text);
//		configureActiveComponet(b);

		return b;
	}

	private List createList(Object parent, String text, Object layout)
	{
		List list = new List(getComposite(parent), DOUBLE_BUFFER | SWT.BORDER);
		list.add(text);
		list.setLayoutData(layout);
		return list;
	}

	private StyledText createTextArea(Object parent, String text, String layout)
	{
		return createTextArea(parent, text, layout, SWT.MULTI | SWT.WRAP | SWT.BORDER | DOUBLE_BUFFER);
	}

	private StyledText createTextArea(Object parent, String text, String layout, int style)
	{
		StyledText ta = new StyledText(getComposite(parent), SWT.MULTI | SWT.WRAP | style | DOUBLE_BUFFER);
		ta.setText(text);
		ta.setLayoutData(layout != null ? layout : text);

//		configureActiveComponet(ta);

		return ta;
	}

	public Composite getComposite(Object c)
	{
		if (c instanceof Control)
			return (Composite) c;

		return (Composite) ((TabItem) c).getControl();
	}

	private Font deriveFont(Control cont, int style, int height)
	{
		Font f = cont.getFont();
		FontData fd = f.getFontData()[0];
		if (style != SWT.DEFAULT)
			fd.setStyle(style);

		if (height != -1)
			fd.setHeight(height);

		Font font = new Font(display, fd);
		cont.setFont(font);
		return font;
	}

//	private Control configureActiveComponet(Control c)
//	{
//		c.addMouseMotionListener(toolTipListener);
//		c.addMouseListener(constraintListener);
//		return c;
//	}

	private void addSeparator(Object panel, String text)
	{
		Label l = createLabel(panel, text, "gaptop para, span, split 2");
		l.setForeground(new Color(display, 0, 70, 213));

		Label s = new Label(getComposite(panel), SWT.SEPARATOR | SWT.HORIZONTAL | DOUBLE_BUFFER);
		s.setLayoutData("gapleft rel, gaptop para, growx");

//      configureActiveComponet(s);
	}

//	private class ConstraintListener extends MouseAdapter
//	{
//		public void mousePressed(MouseEvent e)
//		{
//			if (e.isPopupTrigger())
//				react(e);
//		}
//
//		public void mouseReleased(MouseEvent e)
//		{
//			if (e.isPopupTrigger())
//				react(e);
//		}
//
//		public void react(MouseEvent e)
//		{
//			Control c = (Control) e.getSource();
//			LayoutManager lm = c.getParent().getLayout();
//			if (lm instanceof SwtMigLayout == false)
//				lm = c.getLayout();
//
//			if (lm instanceof SwtMigLayout) {
//				MigLayout ffl = (MigLayout) lm;
//				boolean isComp = ffl.isManagingComponent(c);
//				String compConstr = isComp ? ffl.getComponentConstraints(c) : null;
//				String rowsConstr = isComp ? null : ffl.getRowConstraints();
//				String colsConstr = isComp ? null : ffl.getColumnConstraints();
//				String layoutConstr = isComp ? null : ffl.getLayoutConstraints();
//
//				ConstraintsDialog cDlg = new ConstraintsDialog(SwingDemo.this, layoutConstr, rowsConstr, colsConstr, compConstr);
//				cDlg.pack();
//				cDlg.setLocationRelativeTo(c);
//
//				if (cDlg.showDialog()) {
//					try {
//						if (isComp) {
//							String constrStr = cDlg.componentConstrTF.getText().trim();
//							ffl.setComponentConstraints(c, constrStr);
//							if (c instanceof Button) {
//								c.setFont(BUTT_FONT);
//								((Button) c).setText(constrStr.length() == 0 ? "<Empty>" : constrStr);
//							}
//						} else {
//							ffl.setLayoutConstraints(cDlg.layoutConstrTF.getText());
//							ffl.setRowConstraints(cDlg.rowsConstrTF.getText());
//							ffl.setColumnConstraints(cDlg.colsConstrTF.getText());
//						}
//					} catch(Exception ex) {
//						StringWriter sw = new StringWriter();
//						ex.printStackTrace(new PrintWriter(sw));
//						JOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(c), sw.toString(), "Error parsing Constraint!", JOptionPane.ERROR_MESSAGE);
//						return;
//					}
//
//					c.invalidate();
//					c.getParent().validate();
//				}
//			}
//		}
//	}
//
//	private static class ToolTipListener extends MouseMotionAdapter
//	{
//		public void mouseMoved(MouseEvent e)
//		{
//			Control c = (Control) e.getSource();
//			LayoutManager lm = c.getParent().getLayout();
//			if (lm instanceof SwtMigLayout) {
//				String constr = ((MigLayout) lm).getComponentConstraints(c);
//				c.setToolTipText((constr != null ? ("\"" + constr + "\"") : "null"));
//			}
//		}
//	}
//
//	private static class ConstraintsDialog extends JDialog implements ActionListener, KeyEventDispatcher
//	{
//		private static final Color ERROR_COLOR = new Color(255, 180, 180);
//		private final JPanel mainPanel = new JPanel(parent, new SwtMigLayout("fillx,flowy,ins dialog",
//		                                                               "[fill]",
//		                                                               "2[]2"));
//		final Text layoutConstrTF;
//		final Text rowsConstrTF;
//		final Text colsConstrTF;
//		final Text componentConstrTF;
//
//		private final Button okButt = new Button("OK");
//		private final Button cancelButt = new Button("Cancel");
//
//		private boolean okPressed = false;
//
//		public ConstraintsDialog(Frame owner, String layoutConstr, String rowsConstr, String colsConstr, String compConstr)
//		{
//			super(owner, (compConstr != null ? "Edit Component Constraints" : "Edit Container Constraints"), true);
//
//			layoutConstrTF = createConstraintField(layoutConstr);
//			rowsConstrTF = createConstraintField(rowsConstr);
//			colsConstrTF = createConstraintField(colsConstr);
//			componentConstrTF = createConstraintField(compConstr);
//
//			if (componentConstrTF != null) {
//				mainPanel.add(new Label("Component Constraints"));
//				mainPanel.add(componentConstrTF);
//			}
//
//			if (layoutConstrTF != null) {
//				mainPanel.add(new Label("Container Layout Constraints"));
//				mainPanel.add(layoutConstrTF);
//			}
//
//			if (rowsConstrTF != null) {
//				mainPanel.add(new Label("Container Row Constraints"), "gaptop unrel");
//				mainPanel.add(rowsConstrTF);
//			}
//
//			if (colsConstrTF != null) {
//				mainPanel.add(new Label("Container Column Constraints"), "gaptop unrel");
//				mainPanel.add(colsConstrTF);
//			}
//
//			mainPanel.add(okButt, "tag ok,split,flowx,gaptop 15");
//			mainPanel.add(cancelButt, "tag cancel,gaptop 15");
//
//			setContentPane(mainPanel);
//
//			okButt.addActionListener(this);
//			cancelButt.addActionListener(this);
//		}
//
//		public void addNotify()
//		{
//			super.addNotify();
//			KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this);
//		}
//
//		public void removeNotify()
//		{
//			KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this);
//			super.removeNotify();
//		}
//
//		public boolean dispatchKeyEvent(KeyEvent e)
//		{
//			if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
//				dispose();
//			return false;
//		}
//
//		public void actionPerformed(ActionEvent e)
//		{
//			if (e.getSource() == okButt)
//				okPressed = true;
//			dispose();
//		}
//
//		private Text createConstraintField(String text)
//		{
//			if (text == null)
//				return null;
//
//			final Text tf = new Text(text, 50);
//			tf.setFont(new Font("monospaced", Font.PLAIN, 12));
//
//			tf.addKeyListener(new KeyAdapter() {
//				public void keyPressed(KeyEvent e)
//				{
//					if (e.getKeyCode() == KeyEvent.VK_ENTER) {
//						okButt.doClick();
//						return;
//					}
//
//					javax.swing.Timer timer = new Timer(50, new ActionListener() {
//						public void actionPerformed(ActionEvent e)
//						{
//							String constr = tf.getText();
//							try {
//								if (tf == layoutConstrTF) {
//									MigLayout.validateLayoutConstraint(constr);
//								} else if (tf == rowsConstrTF) {
//									MigLayout.validateRowConstraints(constr);
//								} else if (tf == colsConstrTF) {
//									MigLayout.validateColumnConstraints(constr);
//								} else if (tf == componentConstrTF) {
//									MigLayout.validateComponentConstraint(constr);
//								}
//								tf.setBackground(Color.WHITE);
//								okButt.setEnabled(true);
//							} catch(Exception ex) {
//								tf.setBackground(ERROR_COLOR);
//								okButt.setEnabled(false);
//							}
//						}
//					});
//					timer.setRepeats(false);
//					timer.start();
//				}
//			});
//
//			return tf;
//		}
//
//		private boolean showDialog()
//		{
//			setVisible(true);
//			return okPressed;
//		}
//	}

}