01: package test.check;
02:
03: import java.awt.*;
04:
05: import javax.swing.*;
06:
07: import org.jvnet.substance.skin.SubstanceBusinessBlackSteelLookAndFeel;
08:
09: import com.jgoodies.forms.builder.DefaultFormBuilder;
10: import com.jgoodies.forms.layout.FormLayout;
11:
12: public class AlignmentPanel {
13:
14: public static JComponent getAlignmentPanel() {
15: FormLayout lm = new FormLayout(
16: "right:pref, 4dlu, left:pref:grow", "");
17: DefaultFormBuilder builder = new DefaultFormBuilder(lm,
18: new ScrollablePanel());
19: builder.setDefaultDialogBorder();
20:
21: for (int fontSize = 11; fontSize < 25; fontSize++) {
22: builder.append("size " + fontSize, getSubPanel(fontSize));
23: }
24:
25: return new JScrollPane(builder.getPanel());
26: }
27:
28: private static JPanel getSubPanel(int size) {
29: JPanel result = new JPanel(new FlowLayout(FlowLayout.LEFT));
30:
31: Font font = new Font("Tahoma", Font.PLAIN, size);
32:
33: JTextField tf = new JTextField("sample");
34: tf.setFont(font);
35: result.add(tf);
36:
37: JFormattedTextField ftf = new JFormattedTextField("sample");
38: ftf.setFont(font);
39: result.add(ftf);
40:
41: JPasswordField pf = new JPasswordField("sample");
42: pf.setFont(font);
43: result.add(pf);
44:
45: JComboBox cb = new JComboBox(new Object[] { "sample" });
46: cb.setFont(font);
47: result.add(cb);
48:
49: JComboBox ecb = new JComboBox(new Object[] { "sample" });
50: ecb.setFont(font);
51: ecb.setEditable(true);
52: result.add(ecb);
53:
54: JSpinner s = new JSpinner(new SpinnerListModel(new Object[] {
55: "sample0", "sample", "sample2" }));
56: s.getModel().setValue("sample");
57: s.setFont(font);
58: result.add(s);
59:
60: return result;
61: }
62:
63: public static void main(String[] args) throws Exception {
64: JFrame.setDefaultLookAndFeelDecorated(true);
65: UIManager
66: .setLookAndFeel(new SubstanceBusinessBlackSteelLookAndFeel());
67: SwingUtilities.invokeLater(new Runnable() {
68: public void run() {
69: JFrame frame = new JFrame("Alignment");
70: frame.setSize(600, 400);
71: frame.setLocationRelativeTo(null);
72: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
73:
74: frame.add(getAlignmentPanel(), BorderLayout.CENTER);
75: frame.setVisible(true);
76: }
77: });
78: }
79: }
|