diff options
Diffstat (limited to 'prototypes/miglayout/net/miginfocom/examples/Example01.java')
-rw-r--r-- | prototypes/miglayout/net/miginfocom/examples/Example01.java | 43 |
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);
+ }
+ });
+ }
+}
|