Re: JComboBox cell renderer doesn't render the top item
- From: Kari Ikonen <mr.kari.ikonen@xxxxxxxxx>
- Date: Thu, 24 Nov 2005 22:51:31 +0200
hiwa wrote:
> Below is an SSCCE for the problem. The renderer renders
> item text in the drop down list in italic font. But it doesn't render
> the top item of the box in italic. What could be the solution. T.I.A.
Problem is the fact that BasicComboBoxUI will do following for the returned
list cell renderer:
c.setFont(comboBox.getFont());
i.e. it enforces font of the combobox into one defined for combobox.
One workaround for this is this:
private static final class ItalicRenderer
extends DefaultListCellRenderer
{
private final JComboBox mComboBox;
public ItalicRenderer(final JComboBox pComboBox) {
mComboBox = pComboBox;
}
...
public Component getListCellRendererComponent(
...
mComboBox.setFont(newFont);
return this;
}
}
--
KI -- http://kari.world.dy.fi
.
- Follow-Ups:
- Re: JComboBox cell renderer doesn't render the top item
- From: Christian Kaufhold
- Re: JComboBox cell renderer doesn't render the top item
- References:
- Prev by Date: Re: JComboBox cell renderer doesn't render the top item
- Next by Date: Re: JComboBox cell renderer doesn't render the top item
- Previous by thread: Re: JComboBox cell renderer doesn't render the top item
- Next by thread: Re: JComboBox cell renderer doesn't render the top item
- Index(es):
Relevant Pages
|