This seems to be a verified issue with SWING
http://forums.sun.com/thread.jspa?threadID=385730
I'm currently trying to set the tab tooltip text to JTabbedPane, but when I do this, I can no longer select the tab because the tooltip has added a mouse listener that consumes events.
Does anyone know of a workaround that allows me to save tooltips and my mouse events? Thank.
As requested, here is my SSCCE
package jtabbedbug;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
public class JTabBug{
public static void main(String[] args) {
JTabbedPane jTabbedPane = new JTabbedPane();
jTabbedPane.addTab("Red", new JLabel("Roses"));
jTabbedPane.addTab("Blue", new JLabel("Skies"));
jTabbedPane.addTab("Green", new JLabel("Grass"));
for (int i = 0; i < jTabbedPane.getTabCount(); i++) {
JLabel tabComponent = new JLabel(jTabbedPane.getTitleAt(i));
tabComponent.setToolTipText("Tip: " + tabComponent.getText());
jTabbedPane.setTabComponentAt(i, tabComponent);
}
JFrame jFrame = new JFrame("Testing");
jFrame.add(jTabbedPane);
jFrame.setSize(400, 500);
jFrame.setVisible(true);
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
source
share