diff options
Diffstat (limited to 'prototypes/miglayout/net/miginfocom/examples/Example02.java')
-rw-r--r-- | prototypes/miglayout/net/miginfocom/examples/Example02.java | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/prototypes/miglayout/net/miginfocom/examples/Example02.java b/prototypes/miglayout/net/miginfocom/examples/Example02.java new file mode 100644 index 00000000..31ef9286 --- /dev/null +++ b/prototypes/miglayout/net/miginfocom/examples/Example02.java @@ -0,0 +1,53 @@ +package net.miginfocom.examples; + +import net.miginfocom.swing.MigLayout; + +import javax.swing.*; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.EtchedBorder; + +public class Example02 +{ + private static JPanel createPanel() + { + JPanel panel = new JPanel(new MigLayout()); + + panel.add(createLabel("West Panel"), "dock west"); + panel.add(createLabel("North 1 Panel"), "dock north"); + panel.add(createLabel("North 2 Panel"), "dock north"); + panel.add(createLabel("South Panel"), "dock south"); + panel.add(createLabel("East Panel"), "dock east"); + panel.add(createLabel("Center Panel"), "grow, push"); // "dock center" from v3.0 + + return panel; + } + + private static JLabel createLabel(String text) + { + JLabel label = new JLabel(text); + label.setHorizontalAlignment(JLabel.CENTER); + label.setBorder(new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 10, 5, 10))); + return label; + } + + 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 02"); + frame.getContentPane().add(createPanel()); + frame.pack(); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.setVisible(true); + } + }); + } + +} |