/Users/lyon/j4p/src/gui/run/RunLabelTextFieldPanel.java

1    package gui.run; 
2     
3    import javax.swing.*; 
4    import java.awt.*; 
5     
6    /** 
7     * DocJava, Inc. 
8     * http://www.docjava.com 
9     * Programmer: dlyon 
10    * Date: Mar 31, 2004 
11    * Time: 7:36:31 PM 
12    */ 
13   class RunLabelTextFieldPanel extends JPanel { 
14       public RunLabelTextFieldPanel( RunTextFieldOld tf) { 
15           setLayout(new javax.swing.BoxLayout(this,BoxLayout.Y_AXIS)); 
16           //setLayout(new javax.swing.ScrollPaneLayout()); 
17           add(tf, BorderLayout.CENTER); 
18           add(getLabel( tf), BorderLayout.WEST); 
19       } 
20    
21       private RunLabel getLabel( RunTextFieldOld tf) { 
22           RunLabel rl = new RunLabel(tf.getOriginalText()); 
23           tf.setText(""); 
24           return rl; 
25       } 
26    
27       public static void main(String args[]) { 
28           gui.ClosableJFrame cf = new gui.ClosableJFrame("RunTextField"); 
29           java.awt.Container c = cf.getContentPane(); 
30           c.add(new RunLabelTextFieldPanel(new RunTextFieldOld("[Name") { 
31               public void run() { 
32                   System.out.println(getText()); 
33               } 
34           })); 
35           c.add(new RunLabelTextFieldPanel(new RunTextFieldOld("[House/Street") { 
36               public void run() { 
37                   System.out.println(getText()); 
38               } 
39           })); 
40           RunLabelTextFieldPanel runLabelTextFieldPanel = new RunLabelTextFieldPanel(new RunTextFieldOld("[City") { 
41                       public void run() { 
42                           System.out.println(getText()); 
43                       } 
44                   }); 
45           c.add(runLabelTextFieldPanel); 
46           runLabelTextFieldPanel.invalidate(); 
47           c.setLayout(new java.awt.GridLayout(4, 0)); 
48           c.invalidate(); 
49           cf.setSize(200, 200); 
50           cf.setVisible(true); 
51       } 
52   } 
53