-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
5.0
-
Fix Understood
-
x86
-
windows_xp
Name: gm110360 Date: 09/24/2004
FULL PRODUCT VERSION :
1.4.2_04 and 1.5 RC
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
JList delegates getToolTipText() to the JList renderer component.
It allows to set a tooltip text for each JList item, from the renderer.
The delegation is not done for getToolTipLocation(). As a result, overriding the default tooltip location is not possible.
Overridding JList is a workaround when using JList directly.
But no workaround is possible when setting tooltip in a JComboBox (that delegates display to JList).
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.MouseEvent;
import javax.swing.*;
public class ComboTooltipTest {
private static class MyListRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
super.getListCellRendererComponent(
list,
value,
index,
isSelected,
cellHasFocus);
if (value==null) return this;
super.setToolTipText("My tooltip for "+value);
return this;
}
public Point getToolTipLocation(MouseEvent event) {
System.out.println("getToolTipLocation");
return new Point(getWidth()+5,0);
}
}
public static void main(String[] args) {
JComboBox combo=new JComboBox(new String[] { "value1","value2","value3"});
combo.setRenderer(new MyListRenderer());
JFrame f=new JFrame();
f.getContentPane().setLayout(new FlowLayout());
f.getContentPane().add(combo);
f.setSize(300,200);
f.setVisible(true);
}
}
---------- END SOURCE ----------
(Incident Review ID: 311730)
======================================================================
FULL PRODUCT VERSION :
1.4.2_04 and 1.5 RC
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
JList delegates getToolTipText() to the JList renderer component.
It allows to set a tooltip text for each JList item, from the renderer.
The delegation is not done for getToolTipLocation(). As a result, overriding the default tooltip location is not possible.
Overridding JList is a workaround when using JList directly.
But no workaround is possible when setting tooltip in a JComboBox (that delegates display to JList).
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.MouseEvent;
import javax.swing.*;
public class ComboTooltipTest {
private static class MyListRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
super.getListCellRendererComponent(
list,
value,
index,
isSelected,
cellHasFocus);
if (value==null) return this;
super.setToolTipText("My tooltip for "+value);
return this;
}
public Point getToolTipLocation(MouseEvent event) {
System.out.println("getToolTipLocation");
return new Point(getWidth()+5,0);
}
}
public static void main(String[] args) {
JComboBox combo=new JComboBox(new String[] { "value1","value2","value3"});
combo.setRenderer(new MyListRenderer());
JFrame f=new JFrame();
f.getContentPane().setLayout(new FlowLayout());
f.getContentPane().add(combo);
f.setSize(300,200);
f.setVisible(true);
}
}
---------- END SOURCE ----------
(Incident Review ID: 311730)
======================================================================