View Javadoc

1   package net.wotonomy.test;
2   
3   import java.awt.BorderLayout;
4   import java.awt.Component;
5   import java.awt.Insets;
6   import java.util.Vector;
7   
8   import javax.swing.JCheckBox;
9   import javax.swing.JComboBox;
10  import javax.swing.JPanel;
11  import javax.swing.JScrollPane;
12  import javax.swing.JSlider;
13  import javax.swing.JTable;
14  import javax.swing.JTextField;
15  import javax.swing.border.EmptyBorder;
16  import javax.swing.text.JTextComponent;
17  
18  import net.wotonomy.ui.swing.components.BetterFlowLayout;
19  import net.wotonomy.ui.swing.components.ButtonPanel;
20  import net.wotonomy.ui.swing.components.InfoPanel;
21  
22  /***
23  * A master-detail panel with a list, some 
24  * textfields and some buttons.
25  */
26  public class TestPanel extends JPanel 
27  {    
28  //	public JList list;
29  	public JTable table;
30      public InfoPanel infoPanel;
31  	public ButtonPanel savePanel;
32  	public ButtonPanel buttonPanel;
33  	public JTextComponent firstNameField;
34  	public JTextComponent middleNameField, lastNameField;
35  	public JComboBox dateBox, monthBox, yearBox;
36  	public JSlider slider;
37  	public JCheckBox checkbox;
38  	
39      public TestPanel()
40      {
41          this.setLayout( new BorderLayout( 10, 10 ) );
42      	this.setBorder( new EmptyBorder( 10, 10, 10, 10 ) );
43  
44          JPanel overviewPanel = new JPanel();
45          overviewPanel.setLayout( new BorderLayout() );
46          
47  		//list = new JList();
48          //JScrollPane scrollPane = new JScrollPane( list );
49  
50  		table = new JTable();
51          JScrollPane scrollPane = new JScrollPane( table );
52          
53          overviewPanel.add( scrollPane, BorderLayout.CENTER );
54          
55          this.add( overviewPanel, BorderLayout.CENTER );
56  		
57          infoPanel = new InfoPanel();
58          infoPanel.setColumns( 1 );
59  
60  		// name fields
61  		firstNameField = new JTextField(); 
62  //		infoPanel.addPair( "First Name", firstNameField );
63  		middleNameField = new JTextField();
64  //		infoPanel.addPair( "Middle Name", middleNameField );
65  		lastNameField = new JTextField();
66  //		infoPanel.addPair( "Last Name", lastNameField );
67       	checkbox = new JCheckBox();
68  
69  		infoPanel.addRow( "Name", new Component[] { 
70  			firstNameField, middleNameField, lastNameField, checkbox } );
71  		
72  		// date comboboxen
73  		Vector datesList = new Vector();
74  		for ( int i = 1; i < 32; i++ ) datesList.add( new Integer( i ) );
75  		dateBox = new JComboBox( datesList );
76          dateBox.setEditable( true );
77  		monthBox = new JComboBox();
78  		yearBox = new JComboBox();
79  		infoPanel.addRow( "Create Date",  
80  			dateBox, monthBox, yearBox );
81  			
82  		// year slider
83  		infoPanel.addRow( "Day of Month", slider = new JSlider(
84  			JSlider.HORIZONTAL, 1, 31, 1 ) );
85  		
86  		// navigation buttons
87          
88          JPanel navigationPanel = new JPanel();
89          navigationPanel.setLayout( new BorderLayout() );
90          
91          buttonPanel = new ButtonPanel( new String[] { "Tree View", "Add", "Remove" } );
92          buttonPanel.setAlignment( BetterFlowLayout.LEFT );
93          buttonPanel.setInsets( new Insets( 0, 0, 0, 0 ) );
94          navigationPanel.add( buttonPanel, BorderLayout.WEST );
95  		
96          savePanel = new ButtonPanel( new String[] { "Refresh All", "Commit" } );
97          savePanel.setAlignment( BetterFlowLayout.RIGHT );
98          navigationPanel.add( savePanel, BorderLayout.EAST );
99  
100         // bottom panel layout
101         
102         JPanel bottomPanel = new JPanel();
103         bottomPanel.setLayout( new BorderLayout() );
104         bottomPanel.add( infoPanel, BorderLayout.NORTH );
105         bottomPanel.add( navigationPanel, BorderLayout.SOUTH );
106         
107 		this.add( bottomPanel, BorderLayout.SOUTH );
108    }
109     
110 }