295 |
*/ |
*/ |
296 |
public Dimension getMinimumSize(JComponent c) |
public Dimension getMinimumSize(JComponent c) |
297 |
{ |
{ |
298 |
|
Dimension d = getDisplaySize(); |
299 |
MetalComboBoxButton b = (MetalComboBoxButton) arrowButton; |
MetalComboBoxButton b = (MetalComboBoxButton) arrowButton; |
|
Icon icon = b.getComboIcon(); |
|
300 |
Insets insets = b.getInsets(); |
Insets insets = b.getInsets(); |
|
Dimension d = getDisplaySize(); |
|
301 |
int insetsH = insets.top + insets.bottom; |
int insetsH = insets.top + insets.bottom; |
302 |
int insetsW = insets.left + insets.right; |
int insetsW = insets.left + insets.right; |
303 |
int iconWidth = icon.getIconWidth() + 6; |
if (!comboBox.isEditable()) |
304 |
return new Dimension(d.width + insetsW + iconWidth, |
{ |
305 |
d.height + insetsH); |
Icon icon = b.getComboIcon(); |
306 |
|
int iconWidth = icon.getIconWidth() + 6; |
307 |
|
return new Dimension(d.width + insetsW + iconWidth, d.height + insetsH); |
308 |
|
} |
309 |
|
else |
310 |
|
// FIXME: the following dimensions pass most of the Mauve tests, but |
311 |
|
// I don't yet understand the logic behind this...it is probably wrong |
312 |
|
return new Dimension(d.width + insetsW + (d.height + insetsH) - 4, |
313 |
|
d.height + insetsH + 1); |
314 |
} |
} |
315 |
|
|
316 |
|
/** |
317 |
|
* Configures the editor for this combo box. |
318 |
|
*/ |
319 |
|
public void configureEditor() |
320 |
|
{ |
321 |
|
ComboBoxEditor cbe = comboBox.getEditor(); |
322 |
|
if (cbe != null) |
323 |
|
{ |
324 |
|
cbe.getEditorComponent().setFont(comboBox.getFont()); |
325 |
|
cbe.setItem(comboBox.getSelectedItem()); |
326 |
|
cbe.addActionListener(comboBox); |
327 |
|
} |
328 |
|
} |
329 |
|
|
330 |
|
/** |
331 |
|
* Unconfigures the editor for this combo box. |
332 |
|
*/ |
333 |
|
public void unconfigureEditor() |
334 |
|
{ |
335 |
|
ComboBoxEditor cbe = comboBox.getEditor(); |
336 |
|
if (cbe != null) |
337 |
|
{ |
338 |
|
cbe.getEditorComponent().setFont(null); |
339 |
|
cbe.setItem(null); |
340 |
|
cbe.removeActionListener(comboBox); |
341 |
|
} |
342 |
|
} |
343 |
|
|
344 |
|
/** |
345 |
|
* Lays out the ComboBox |
346 |
|
*/ |
347 |
|
public void layoutComboBox(Container parent, |
348 |
|
MetalComboBoxUI.MetalComboBoxLayoutManager manager) |
349 |
|
{ |
350 |
|
manager.layoutContainer(parent); |
351 |
|
} |
352 |
} |
} |