1 package org.devaki.nextobjects.ui.components;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 import java.util.Vector;
22 import javax.swing.JComboBox;
23 /***
24 * This class overwrite of the 'JComboBox' component
25 * @author <a href="mailto:eflorent@devaki.org">Emmanuel Florent</a>
26 */
27 public class CustomComboBox extends JComboBox
28 {
29 /***
30 * Create a 'CustomComboBox' object
31 * @param tooltipText Text that appears as a Tool Tip
32 * @param data Vector to fill in the component
33 * @param isEnabled Is the button enabled or not
34 * @param selectedIndex Indicate the initial selected index
35 */
36 public CustomComboBox(
37 final Vector data,
38 final int selectedIndex,
39 final String tooltipText,
40 final boolean isEnabled)
41 {
42 super(data);
43
44 this.setSelectedIndex(selectedIndex);
45
46 if (tooltipText.length() != 0)
47 {
48 this.setToolTipText(tooltipText);
49 }
50
51 this.setEnabled(isEnabled);
52 }
53 /***
54 * Create a 'CustomComboBox' object
55 * @param tooltipText Text that appears as a Tool Tip
56 * @param data Array of String objects to fill in the component
57 * @param isEnabled Is the button enabled or not
58 * @param selectedIndex Indicate the initial selected index
59 */
60 public CustomComboBox(
61 final String[] data,
62 final int selectedIndex,
63 final String tooltipText,
64 final boolean isEnabled)
65 {
66 super(data);
67
68 this.setSelectedIndex(selectedIndex);
69
70 if (tooltipText.length() != 0)
71 {
72 this.setToolTipText(tooltipText);
73 }
74
75 this.setEnabled(isEnabled);
76 }
77 /***
78 * Create a 'CustomComboBox' object
79 * @param tooltipText Text that appears as a Tool Tip
80 * @param isEnabled Is the button enabled or not
81 */
82 public CustomComboBox(final String tooltipText, final boolean isEnabled)
83 {
84
85 if (tooltipText.length() != 0)
86 {
87 this.setToolTipText(tooltipText);
88 }
89
90 this.setEnabled(isEnabled);
91 }
92 /***
93 * Fill in a 'CustomComboBox' component
94 * @param data Vector that initializes the component
95 */
96 public final void setData(final Vector data)
97 {
98 this.removeAllItems();
99 for (int i = 0; i < data.size(); i++)
100 {
101 this.addItem(data.elementAt(i));
102 }
103 }
104 }