-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0, 1.4.1
-
mantis
-
x86
-
windows_2000
Name: gm110360 Date: 05/10/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION : Microsoft Windows 2000
[Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
Tool tip updating is different when using the Java Look and
Feel, versus using the Windows Look and Feel, only in Java
1.4. When the Windows look and feel is used, components
behind the tool tips get updated poorly. Updates occur
cleanly when using the Java Look and Feel, and under Java
1.3.x.
REGRESSION. Last worked in version 1.3.1
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1.Run the program included
2.
3.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Tooltips should work the same in the Windows look and feel
as they do in the Java look and feel.
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// This program demonstrates a strange difference in tool tip behavior when
// using the Java Look and Feel versus the Windows Look and Feel,
// under Java 1.4.
// The ToolTips are displayed cleanly when the Java Look and Feel is used,
// but cause artifacting and poor-looking display when the Windows Look and Feel
// is used. It is caused by a "slow" paintComponent() method. In my real
// application, a JPanel derivative paints a complex graph, which takes on
// the order of 30ms. Here, I've made the paintComponent() method take
// ~50ms to complete in order to demonstrate the effect. Note that the update
// behavior is quite different with the different Look and Feels. They
// behave similarly under 1.3.x JVMs.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WeirdToolTip extends JFrame {
public WeirdToolTip() {
super("Weird Tool Tip");
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
this.getContentPane().setLayout(new BorderLayout(5, 5));
this.getContentPane().add(BorderLayout.CENTER, new WeirdCanvas
());
final JFrame frame = this;
JRadioButton nativeButton = new JRadioButton("Native UI");
nativeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
UIManager.setLookAndFeel
(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI
(frame);
} catch (Exception ex) {
System.out.println("Could not set
native look and feel: " + ex);
}
}
});
JRadioButton javaButton = new JRadioButton("Java UI");
javaButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
UIManager.setLookAndFeel
(UIManager.getCrossPlatformLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI
(frame);
} catch (Exception ex) {
System.out.println("Could not set
native look and feel: " + ex);
}
}
});
javaButton.setSelected(true);
ButtonGroup bg = new ButtonGroup();
bg.add(nativeButton);
bg.add(javaButton);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
buttonPanel.add(nativeButton);
buttonPanel.add(javaButton);
this.getContentPane().add(BorderLayout.SOUTH, buttonPanel);
this.pack();
this.setVisible(true);
}
public static void main(String[] argv) {
new WeirdToolTip();
}
class WeirdCanvas extends JPanel {
public WeirdCanvas() {
setPreferredSize(new Dimension(200, 200));
ToolTipManager.sharedInstance().registerComponent(this);
}
public void paintComponent(Graphics g) {
g.setColor(Color.white);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.red);
g.fillOval(20, 20, getWidth() - 40, getHeight() - 40);
// Simulate a long draw operation
try { Thread.sleep(50); } catch (Exception e) { }
}
public String getToolTipText(MouseEvent e) {
return "Position: " + e.getX() + ", " + e.getY();
}
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
It's not a true workaround, but it's decent: simply discard
all but every 5 or 10 calls to getToolTipText. This gives
the slow component enough time to repaint. It also means
the tool tips are sluggish.
Release Regression From : 1.3.1_03
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 146406)
======================================================================
- duplicates
-
JDK-4771592 REGRESSION: Tooltip intercepts mouse click when using WindowsLookAndFeel
-
- Closed
-
- relates to
-
JDK-4759722 Regression:Problem to type traditional Chinese characters in a JTextArea
-
- Resolved
-