[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/50253] New: JRootPane does not override isOptimizedDrawin

From: handydt at gmail dot com
Subject: [Bug classpath/50253] New: JRootPane does not override isOptimizedDrawingEnabled
Date: Wed, 31 Aug 2011 15:31:49 +0000


             Bug #: 50253
           Summary: JRootPane does not override isOptimizedDrawingEnabled
    Classification: Unclassified
           Product: classpath
           Version: 0.98
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: classpath
        AssignedTo: address@hidden
        ReportedBy: address@hidden

In JRootPane.java, the method isOptimizedDrawingEnabled is misspelled, so it
does not override JComponent's method as intended.  The result is that if you
have a glass pane up and a component in the content pane is repainted, that
component pops up over the glass pane.  The glass pane does not get repainted
as it should.

Here is a demo program (TestJRootPane.java):

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.Timer;

 * Demonstrates problem with JRootPane.isOptimizedDrawingEnabled.  The method
is misspelled
 * and, therefor, not overriding the JComponent method as intended.
 * When running this program with the bug, a frame is displayed with a label
 * After 2 seconds, a transparent yellow overlay is displayed using the glass
 * After 2 more seconds, the label's text is changed to "Repainted".  The label
is repainted
 * and appears to be in front of the yellow overlay now.
 * When running this program with the bug fixed, when the label's text is
changed, the label
 * is repainted and remains behind or under the yellow overlay.
public class TestJRootPane
  private class GlassPane extends JComponent
    public void paint(final Graphics g)
      // draw semi-transparent yellow overlay
      g.setColor(new Color(1f, 1f, 0f, .5f));
      g.fillRect(0, 0, getWidth(), getHeight());

  private TestJRootPane()
    final JFrame frame = new JFrame("Test JRootPane");
    final JLabel label1 = createLabel("North");
    JLabel label2 = createLabel("South");

    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.add(label1, BorderLayout.NORTH);
    contentPanel.add(label2, BorderLayout.SOUTH);

    frame.setGlassPane(new GlassPane());
    frame.setSize(200, 200);

    Timer showGlassPaneTimer = new Timer(2000, new ActionListener()
      public void actionPerformed(final ActionEvent evt)

    Timer repaintLabelTimer = new Timer(4000, new ActionListener()
      public void actionPerformed(final ActionEvent evt)


  private JLabel createLabel(final String text)
    JLabel label = new JLabel(text);
    return label;

  public static void main(final String[] args)
    SwingUtilities.invokeLater(new Runnable ()
      public void run()
        new TestJRootPane();

reply via email to

[Prev in Thread] Current Thread [Next in Thread]