summaryrefslogtreecommitdiff
path: root/prototypes/miglayout/net/miginfocom/examples/Example01.java
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-03-03 19:23:40 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-03-03 19:23:40 +0000
commitcfbb1096706f6234cf8ac8fb0feefaae8b881ba9 (patch)
treef86d7fb67c7568cdd8284743f07a47cf457851ca /prototypes/miglayout/net/miginfocom/examples/Example01.java
parentcec78aca668fb7b5eba7f60852854697619573ca (diff)
downloadfpGUI-cfbb1096706f6234cf8ac8fb0feefaae8b881ba9.tar.xz
* Added my MiG Layout Manager code to the prototypes diretory while I continue working on the port from Java.
Diffstat (limited to 'prototypes/miglayout/net/miginfocom/examples/Example01.java')
-rw-r--r--prototypes/miglayout/net/miginfocom/examples/Example01.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/prototypes/miglayout/net/miginfocom/examples/Example01.java b/prototypes/miglayout/net/miginfocom/examples/Example01.java
new file mode 100644
index 00000000..c67d935c
--- /dev/null
+++ b/prototypes/miglayout/net/miginfocom/examples/Example01.java
@@ -0,0 +1,43 @@
+package net.miginfocom.examples;
+
+import net.miginfocom.swing.MigLayout;
+
+import javax.swing.*;
+
+/**
+ */
+public class Example01
+{
+ private static JPanel createPanel()
+ {
+ JPanel panel = new JPanel(new MigLayout());
+
+ panel.add(new JLabel("First Name"));
+ panel.add(new JTextField(15));
+ panel.add(new JLabel("Surname"), "gap unrelated"); // Unrelated size is resolved per platform
+ panel.add(new JTextField(15), "wrap"); // Wraps to the next row
+ panel.add(new JLabel("Address"));
+ panel.add(new JTextField(), "span, growx"); // Spans cells in row and grows to fit that
+
+ return panel;
+ }
+
+ public static void main(String[] args)
+ {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ try {
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ JFrame frame = new JFrame("Example 01");
+ frame.getContentPane().add(createPanel());
+ frame.pack();
+ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ frame.setVisible(true);
+ }
+ });
+ }
+}