Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4994151

REGRESSION: Bug when setting the foreground of a JWindow

XMLWordPrintable

    • b41
    • x86
    • linux



      Name: pr15447 Date: 02/12/2004


      FULL PRODUCT VERSION :
      >java -version
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      > uname -a
      Linux lomu.noumea.spc.int 2.4.18-14smp #1 SMP Wed Sep 4 12:34:47 EDT 2002 i686 i686 i386 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      A java.lang.ClassCastException is thrown when setting the foreground of a JWindow after it has been made visible

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a JWindow, make it visible, set its foreground color.

      By the way the above regression combo box (on the bug report page) is too small (not long enougth).
      I cannot see the version at the end of the text when I choose the last working release (I choose the middle one => probably Java 2 SDK, Standard Edition 1.4.x).
      It happens in Windows XP SP1, IE6, latest patch, font smoothing enabled with ClearType.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The window should apear on screen and no exception should be thrown.
      Code works OK on Windows with JDK 1.5 beta1
      Code used to work OK on Windows an Linux with JDK 1.4.x and 1.3.x.


      ACTUAL -
      The window appears on screen but the program is stopped due to the exception that has been thrown.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.ClassCastException: sun.awt.NullComponentPeer
              at sun.awt.X11.XPanelPeer.setForeground(Unknown Source)
              at java.awt.Component.setForeground(Unknown Source)
              at TestWindow.<init>(TestWindow.java:20)
              at TestWindow.main(TestWindow.java:25)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import javax.swing.*;

      public class TestWindow extends JWindow
      {
        private static Dimension DEFAULT_SIZE = new Dimension(320,
      200);
        
        private static final Color DEFAULT_COLOR = Color.black;
        
        public TestWindow()
        {
          super();
          Dimension size = DEFAULT_SIZE;
          setSize(320,200);
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          setLocation((screenSize.width-size.width)/2,
      (screenSize.height-size.height)/2);
          setVisible(true);
          setForeground(DEFAULT_COLOR);
        }

        public static void main(String[] args)
        {
          new TestWindow();
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use a try {} catch {} block until this bug is fixed.

      Release Regression From : tiger-beta
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 237453)
      ======================================================================

            son Oleg Sukhodolsky (Inactive)
            prr Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: