1    package com.instantbank.common.uiutils;
2    
3    import javax.swing.JTextField;
4    import javax.swing.JLabel;
5    import javax.swing.JPanel;
6    import javax.swing.BoxLayout;
7    import javax.swing.border.EmptyBorder;
8    import javax.swing.BoundedRangeModel;
9    
10   import java.awt.Dimension;
11   import java.awt.Color;
12   import java.awt.event.ActionEvent;
13   import java.awt.event.ActionListener;
14   
15   import com.instantbank.common.uiutils.MessageFrame;
16   
17   /**
18    *  Control formed by a label followed by a JTextField.
19    *
20    * @author InstantBank (Rodrigo Lopez)
21    * @created September 2002
22    */
23   public class LabelText extends JPanel {
24     /**
25      * The text field
26      */
27     private JTextField txf = new JTextField();
28     /**
29      * The label bound to the text field.
30      */
31     private JLabel lb = new JLabel();
32   
33   
34     /**
35      *  Constructor for the LabelText control
36      *
37      * @param lbltext Initial value for the label.
38      * @param text Initial value for the Textfield.
39      * @param c Background color.
40      * @param d Control's preferred size.
41      * @param b Control's border (can be null).
42      * @param editable
43      */
44     public LabelText(String lbltext, String text, Color c,
45                      Dimension d, EmptyBorder b, boolean editable) {
46       lb.setText(lbltext);
47       lb.setBorder(MiscDecoration.rBorder);
48       lb.setBackground(c);
49   
50       if(text != null) {
51         txf.setText(text);
52         txf.setToolTipText(text);
53       }
54   
55       txf.setPreferredSize(d);
56       txf.setEditable(editable);
57       txf.setHorizontalAlignment(JTextField.LEFT);
58   
59       this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
60       this.add(lb);
61       this.add(txf);
62       this.setBackground(c);
63       if(b != null) {
64         this.setBorder(b);
65       }
66   
67     }
68   
69   
70     /**
71      *  Sets the text attribute of the LabelText object
72      *
73      * @param s The new text value
74      */
75     public void setText(String s) {
76       txf.setText(s);
77       txf.setToolTipText(s);
78       BoundedRangeModel brm = txf.getHorizontalVisibility();
79       brm.setValue(0);
80     }
81   
82   
83     /**
84      *  Gets the text attribute of the LabelText object
85      *
86      * @return The text value
87      */
88     public String getText() {
89       return txf.getText();
90     }
91   }
92