1    package com.instantbank.common.uiutils;
2    
3    import javax.swing.JPanel;
4    import javax.swing.JComboBox;
5    import javax.swing.JLabel;
6    import javax.swing.BoxLayout;
7    import java.awt.Color;
8    import java.awt.Dimension;
9    import javax.swing.border.EmptyBorder;
10   
11   /**
12    *  Control formed by a Label followed by a ComboBox
13    *
14    * @author InstantBank (Rodrigo Lopez)
15    * @created September 2002
16    */
17   public class LabelCombo extends JPanel {
18   
19     /**
20      *  The combo box.
21      */
22     private JComboBox cbx = new JComboBox();
23   
24     /**
25      *  The label.
26      */
27     private JLabel lb = new JLabel();
28   
29   
30     /**
31      *  Constructor for the LabelCombo control
32      *
33      * @param lbltext Initial text for the label.
34      * @param cbxtext Initial text for the textfield.
35      * @param c Background color.
36      * @param d Control's preferred size.
37      * @param b Control's border (can be null)
38      */
39     public LabelCombo(String lbltext, String[] cbxtext, Color c,
40                       Dimension d, EmptyBorder b) {
41       lb.setText(lbltext);
42       lb.setBorder(MiscDecoration.rBorder);
43       lb.setBackground(c);
44       for(int i = 0; i < cbxtext.length; i++) {
45         cbx.addItem(cbxtext[i]);
46       }
47   
48       cbx.setPreferredSize(d);
49   
50       this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
51       this.add(lb);
52       this.add(cbx);
53       this.setBackground(c);
54       if(b != null) {
55         this.setBorder(b);
56       }
57     }
58   
59   
60     /**
61      *  Returns the label.
62      *
63      * @return The label value
64      */
65     public JLabel getLabel() {
66       return lb;
67     }
68   
69   
70     /**
71      *  Returns the small combo.
72      *
73      * @return The combo value
74      */
75     public JComboBox getCombo() {
76       return cbx;
77     }
78   }
79