001 package org.springframework.richclient.form;
002
003 import javax.swing.JCheckBox;
004 import javax.swing.JComboBox;
005 import javax.swing.JFrame;
006 import javax.swing.JLabel;
007 import javax.swing.JPanel;
008 import javax.swing.JTextField;
009
010 import org.springframework.richclient.layout.TableLayoutBuilder;
011
012 /**
013 * Simple Panel that mimics a panel created by a visual designer.
014 * @author Peter De Bruycker
015 */
016 public class SimplePanel extends JPanel {
017 private JTextField stringField;
018 private JComboBox comboBox;
019 private JCheckBox checkBox;
020 private JTextField nestedField;
021
022 public SimplePanel() {
023 TableLayoutBuilder builder = new TableLayoutBuilder(this);
024
025 stringField = new JTextField(10);
026 stringField.setName("stringProperty");
027
028 comboBox = new JComboBox(new String[] { "item 0", "item 1", "item 2" });
029 comboBox.setName("comboProperty");
030
031 checkBox = new JCheckBox("checkbox");
032 checkBox.setName("booleanProperty");
033
034 builder.cell(new JLabel("string"));
035 builder.gapCol();
036 builder.cell(stringField);
037 builder.relatedGapRow();
038 builder.cell(new JLabel("combo"));
039 builder.gapCol();
040 builder.cell(comboBox);
041 builder.relatedGapRow();
042 builder.cell(checkBox);
043 builder.relatedGapRow();
044
045 JPanel nestedPanel =new JPanel();
046 nestedField = new JTextField("test");
047 nestedField.setName("nestedField");
048 nestedPanel.add(nestedField);
049
050 builder.cell(nestedPanel);
051
052 builder.getPanel();
053 }
054
055 public static void main(String[] args) {
056 JFrame frame = new JFrame("test");
057 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
058
059 frame.add(new SimplePanel());
060
061 frame.pack();
062 frame.setLocationRelativeTo(null);
063 frame.setVisible(true);
064 }
065
066 public JTextField getStringField() {
067 return stringField;
068 }
069
070 public JComboBox getComboBox() {
071 return comboBox;
072 }
073
074 public JCheckBox getCheckBox() {
075 return checkBox;
076 }
077
078 public JTextField getNestedField() {
079 return nestedField;
080 }
081 }