blob: 31ef9286217192329784aabd5cf7a0d18394338b (
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
|
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);
}
});
}
}
|