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 including a Label a big combo box and a small combo box, in a row.
13    *
14    * @author InstantBank (Rodrigo Lopez)
15    * @created September 2002
16    */
17   public class LabelComboCombo extends JPanel {
18   
19     /**
20      *  The big combo box.
21      */
22     private JComboBox cbxBig = new JComboBox();
23   
24     /**
25      *  The small combo box.
26      */
27     private JComboBox cbxSmall = new JComboBox();
28   
29     /**
30      *  The label.
31      */
32     private JLabel lb = new JLabel();
33   
34   
35     /**
36      *  Constructor for the LabelComboCombo control
37      *
38      * @param lbltext Text for the label.
39      * @param cbxtextBig Initial texts in the big combo.
40      * @param cbxtextSmall Initial texts in the small combo.
41      * @param c Backgroun color.
42      * @param dBig Big Combo preferred size.
43      * @param dSmall Small Combo preferred size.
44      * @param b Control's border.
45      */
46     public LabelComboCombo(String lbltext, String[] cbxtextBig,
47                            String[] cbxtextSmall, Color c,
48                            Dimension dBig, Dimension dSmall, EmptyBorder b) {
49       lb.setText(lbltext);
50       lb.setBorder(MiscDecoration.rBorder);
51       lb.setBackground(c);
52       for(int i = 0; i < cbxtextBig.length; i++) {
53         cbxBig.addItem(cbxtextBig[i]);
54       }
55   
56       for(int i = 0; i < cbxtextSmall.length; i++) {
57         cbxSmall.addItem(cbxtextSmall[i]);
58       }
59   
60       cbxBig.setPreferredSize(dBig);
61       cbxSmall.setPreferredSize(dSmall);
62   
63       this.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
64       this.add(lb);
65       this.add(cbxBig);
66       this.add(cbxSmall);
67       this.setBackground(c);
68       if(b != null) {
69         this.setBorder(b);
70       }
71     }
72   
73   
74     /**
75      *  Returns the label.
76      *
77      * @return The label value
78      */
79     public JLabel getLabel() {
80       return lb;
81     }
82   
83   
84     /**
85      *  Returns the big combo.
86      *
87      * @return The bigCombo value
88      */
89     public JComboBox getBigCombo() {
90       return cbxBig;
91     }
92   
93   
94     /**
95      *  Returns the small combo.
96      *
97      * @return The smallCombo value
98      */
99     public JComboBox getSmallCombo() {
100      return cbxSmall;
101    }
102  
103  
104    /**
105     *  Enables or disables the inner combo boxes.
106     *
107     * @param mode true=enable, false=disable.
108     */
109    public void setEnabled(boolean mode) {
110      cbxSmall.setEnabled(mode);
111      cbxBig.setEnabled(mode);
112    }
113  
114  }
115