48 * @see MetalComboBoxButton |
48 * @see MetalComboBoxButton |
49 * @author Tom Santos |
49 * @author Tom Santos |
50 */ |
50 */ |
51 @SuppressWarnings("serial") // Same-version serialization only |
51 @SuppressWarnings("serial") // Same-version serialization only |
52 public class MetalComboBoxButton extends JButton { |
52 public class MetalComboBoxButton extends JButton { |
|
53 |
|
54 /** |
|
55 * The instance of {@code JComboBox}. |
|
56 */ |
53 protected JComboBox comboBox; |
57 protected JComboBox comboBox; |
|
58 |
|
59 /** |
|
60 * The instance of {@code JList}. |
|
61 */ |
54 protected JList listBox; |
62 protected JList listBox; |
|
63 |
|
64 /** |
|
65 * The instance of {@code CellRendererPane}. |
|
66 */ |
55 protected CellRendererPane rendererPane; |
67 protected CellRendererPane rendererPane; |
|
68 |
|
69 /** |
|
70 * The icon. |
|
71 */ |
56 protected Icon comboIcon; |
72 protected Icon comboIcon; |
|
73 |
|
74 /** |
|
75 * The {@code iconOnly} value. |
|
76 */ |
57 protected boolean iconOnly = false; |
77 protected boolean iconOnly = false; |
58 |
78 |
|
79 /** |
|
80 * Returns the {@code JComboBox}. |
|
81 * |
|
82 * @return the {@code JComboBox} |
|
83 */ |
59 public final JComboBox getComboBox() { return comboBox;} |
84 public final JComboBox getComboBox() { return comboBox;} |
|
85 |
|
86 /** |
|
87 * Sets the {@code JComboBox}. |
|
88 * |
|
89 * @param cb the {@code JComboBox} |
|
90 */ |
60 public final void setComboBox( JComboBox cb ) { comboBox = cb;} |
91 public final void setComboBox( JComboBox cb ) { comboBox = cb;} |
61 |
92 |
|
93 /** |
|
94 * Returns the icon of the {@code JComboBox}. |
|
95 * |
|
96 * @return the icon of the {@code JComboBox} |
|
97 */ |
62 public final Icon getComboIcon() { return comboIcon;} |
98 public final Icon getComboIcon() { return comboIcon;} |
|
99 |
|
100 /** |
|
101 * Sets the icon of the {@code JComboBox}. |
|
102 * |
|
103 * @param i the icon of the {@code JComboBox} |
|
104 */ |
63 public final void setComboIcon( Icon i ) { comboIcon = i;} |
105 public final void setComboIcon( Icon i ) { comboIcon = i;} |
64 |
106 |
|
107 /** |
|
108 * Returns the {@code isIconOnly} value. |
|
109 * |
|
110 * @return the {@code isIconOnly} value |
|
111 */ |
65 public final boolean isIconOnly() { return iconOnly;} |
112 public final boolean isIconOnly() { return iconOnly;} |
|
113 |
|
114 /** |
|
115 * If {@code isIconOnly} is {@code true} then only icon is painted. |
|
116 * |
|
117 * @param isIconOnly if {@code true} then only icon is painted |
|
118 */ |
66 public final void setIconOnly( boolean isIconOnly ) { iconOnly = isIconOnly;} |
119 public final void setIconOnly( boolean isIconOnly ) { iconOnly = isIconOnly;} |
67 |
120 |
68 MetalComboBoxButton() { |
121 MetalComboBoxButton() { |
69 super( "" ); |
122 super( "" ); |
70 DefaultButtonModel model = new DefaultButtonModel() { |
123 DefaultButtonModel model = new DefaultButtonModel() { |
73 } |
126 } |
74 }; |
127 }; |
75 setModel( model ); |
128 setModel( model ); |
76 } |
129 } |
77 |
130 |
|
131 /** |
|
132 * Constructs a new instance of {@code MetalComboBoxButton}. |
|
133 * |
|
134 * @param cb an instance of {@code JComboBox} |
|
135 * @param i an icon |
|
136 * @param pane an instance of {@code CellRendererPane} |
|
137 * @param list an instance of {@code JList} |
|
138 */ |
78 public MetalComboBoxButton( JComboBox cb, Icon i, |
139 public MetalComboBoxButton( JComboBox cb, Icon i, |
79 CellRendererPane pane, JList list ) { |
140 CellRendererPane pane, JList list ) { |
80 this(); |
141 this(); |
81 comboBox = cb; |
142 comboBox = cb; |
82 comboIcon = i; |
143 comboIcon = i; |
83 rendererPane = pane; |
144 rendererPane = pane; |
84 listBox = list; |
145 listBox = list; |
85 setEnabled( comboBox.isEnabled() ); |
146 setEnabled( comboBox.isEnabled() ); |
86 } |
147 } |
87 |
148 |
|
149 /** |
|
150 * Constructs a new instance of {@code MetalComboBoxButton}. |
|
151 * |
|
152 * @param cb an instance of {@code JComboBox} |
|
153 * @param i an icon |
|
154 * @param onlyIcon if {@code true} only icon is painted |
|
155 * @param pane an instance of {@code CellRendererPane} |
|
156 * @param list an instance of {@code JList} |
|
157 */ |
88 public MetalComboBoxButton( JComboBox cb, Icon i, boolean onlyIcon, |
158 public MetalComboBoxButton( JComboBox cb, Icon i, boolean onlyIcon, |
89 CellRendererPane pane, JList list ) { |
159 CellRendererPane pane, JList list ) { |
90 this( cb, i, pane, list ); |
160 this( cb, i, pane, list ); |
91 iconOnly = onlyIcon; |
161 iconOnly = onlyIcon; |
92 } |
162 } |