In the following program (which depends on JOGL), the tooltip of the JLabel
is hidden behind the heavyweight GLCanvas
when the tooltip 'fits' inside the GLCanvas
.
import java.awt.*;
import javax.swing.*;
import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import com.jogamp.opengl.awt.GLCanvas;
public class HeavyWeightTooltipTest {
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false);
try {
UIManager.setLookAndFeel(NimbusLookAndFeel.class.getName());
} catch (Exception aE) {
aE.printStackTrace();
}
showUI();
}
});
}
private static void showUI(){
JFrame frame = new JFrame("TestFrame");
JLabel label = new JLabel("Label with tooltip");
label.setToolTipText("A very long tooltip to ensure it overlaps with the heavyweight component");
frame.add(label, BorderLayout.WEST);
GLCanvas glCanvas = new GLCanvas();
frame.add(glCanvas, BorderLayout.CENTER);
frame.setVisible(true);
frame.setSize(300,300);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
Observations
- It only happens when not using the Aqua look and feel. I could reproduce it with Nimbus and Metal look and feels, but not with the Aqua look and feel.
- It does not happen when using a regular
java.awt.Canvas
, only with the JOGLGLCanvas
(which is an extension ofjava.awt.Canvas
) - The tooltip is rendered correctly when the tooltip is wider than the
GLCanvas
. The problem starts as soon as the tooltip fits into theGLCanvas
(see screenshots at the end of the post) - It does not matter whether I call
ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false)
or not. The problem is always reproducible - It works on Linux and Windows
In case it is relevant, I am using JOGL version 2.3.2 and Java version 1.8.0_65
java version "1.8.0_65" Java(TM) SE Runtime Environment (build 1.8.0_65-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
Tooltip correctly shown
Tooltip hidden behind GLCanvas
Edit: I logged this in the bug tracker of JOGL as bug 1306.