Re: JComboBox cell renderer doesn't render the top item



Hello!

Kari Ikonen <mr.kari.ikonen@xxxxxxxxx> wrote:

> 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 void setFont(Font value)
{
}

protected void setFont_really(Font value)
{
super.setFont(value);
}

and always use setFont_really (alternatively
set a flag in getListCellRendererComponent so that setFont works).
The same must really be done for foreground/background, as has been
discussed before.

> ...
> public Component getListCellRendererComponent(
> ...






> mComboBox.setFont(newFont);

<shudder>


Christian
.



Relevant Pages

  • Re: JComboBox cell renderer doesnt render the top item
    ... The renderer renders ... > item text in the drop down list in italic font. ... i.e. it enforces font of the combobox into one defined for combobox. ... private static final class ItalicRenderer ...
    (comp.lang.java.gui)
  • Re: Editor / Renderer: data flow
    ... When I set an editor and a renderer to a jtable, ... My editor return an Object from getCellEditorValue method. ... I ask this cause I've set an editor with a comboBox to a jxtreetable ... comboBox disappear and the cell remains as before... ...
    (comp.lang.java.gui)
  • Re: Seltsame =?ISO-8859-1?Q?Gr=F6sse_einer_JComboBox?=
    ... Als Model dient ein DefaultComboBoxModel und für die Anzeige benutze ich einen Renderer. ... Das Problem ist, das die Combobox völlig zusammengefallen dargestellt wird, sofern kein Landesteil in der Locale vorhanden ist. ... Oder ist das Leerzeichen kein "ordentliches" Zeichen, aufgrund dessen man die Höhe der Combobox berechnen kann? ... Ein Leerstring ist ein String der Länge 0, ...
    (de.comp.lang.java)
  • Re: How to Create a cellrenderer as part of a combobox in Glade 3.14
    ... But I am able to copy the combobox with the cell renderer into my project. ... Dmitry A. Kazakov ...
    (comp.lang.ada)
  • How to Create a cellrenderer as part of a combobox in Glade 3.14
    ... I used in an earlier version of Glade a Cell renderer as a part of the combobox. ... Is this a problem of Glade 3.14 or what do I have to do to make the combobox work without the renderer? ...
    (comp.lang.ada)