-
Bug
-
Resolution: Fixed
-
P3
-
6u2, 7
-
b10
-
x86
-
linux
-
Verified
There are visual problems with custom renderers in combo boxes in GTK LF. Please try to run attached test app - when run in Metal LF, all three combo boxes look the same, as expected, even if there are various custom renderers set. However, in GTK there are missing borders and inaccurate sizes unless renderer implements UIResource, overrides getName and calls setName from getListCellRendererComponent method:
To get the borders and size right, we need to do:
private static class OKRenderer extends JLabel implements ListCellRenderer, UIResource {
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
// #89393: GTK needs name to render cell renderer "natively"
setName("ComboBox.listRenderer"); // NOI18N
......
return this;
}
// #89393: GTK needs name to render cell renderer "natively"
public String getName() {
String name = super.getName();
return name == null ? "ComboBox.renderer" : name; // NOI18N
}
}
As we (in NetBeans) use combobox.setRenderer on many places, workarounding this issue will be relatively painful for us.
To get the borders and size right, we need to do:
private static class OKRenderer extends JLabel implements ListCellRenderer, UIResource {
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
// #89393: GTK needs name to render cell renderer "natively"
setName("ComboBox.listRenderer"); // NOI18N
......
return this;
}
// #89393: GTK needs name to render cell renderer "natively"
public String getName() {
String name = super.getName();
return name == null ? "ComboBox.renderer" : name; // NOI18N
}
}
As we (in NetBeans) use combobox.setRenderer on many places, workarounding this issue will be relatively painful for us.
- duplicates
-
JDK-6538687 On Ubuntu(Human Theme) JComboBox's drop down back ground color is different from Native
-
- Closed
-