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

Windows 2000 L&F is not initializing properly.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta
    • generic
    • solaris_8
    • Verified

      This problem only appears on machines that don't support Windows L&F, namely any system except Windows.

      Run the program to display the NullPointerException:

      java.lang.NullPointerException
              at com.sun.java.swing.plaf.windows.WindowsLookAndFeel.uninitialize(Windo
      wsLookAndFeel.java:1192)
              at javax.swing.UIManager.setLookAndFeel(UIManager.java:367)
              at javax.swing.UIManager.setLookAndFeel(UIManager.java:403)
              at SimpleTest$SwitchingThread.run(SimpleTest.java:69)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:147)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:421)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:13
      6)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:122)

              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:118)

              at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)

      ----------------------------------------------------------------

      import javax.swing.*;
      import java.awt.*;

      public class SimpleTest extends JFrame {

          private JButton button;

          private final String[] LNFString = {
              "javax.swing.plaf.metal.MetalLookAndFeel",
              "com.sun.java.swing.plaf.motif.MotifLookAndFeel",
              "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"};

          private static int LNFIndex = 0;


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

          public SimpleTest() {
              button = new JButton("Hello");

              getContentPane().add(button);

              setSize(200, 200);
              show();

              while(true) {
                  try {
                      Thread.sleep(2000);
                  } catch(Exception e) {
                      e.printStackTrace();
                  }

                  switchLNF();
              }
          }


          private void switchLNF() {
              waitTillSwitched(this);
          }

          private void waitTillSwitched(Component comp) {
              SwitchingThread rt = new SwitchingThread(comp);

              try {
                  SwingUtilities.invokeAndWait(rt);
              } catch(Exception e) {
                  e.printStackTrace();
              }
          }

          class SwitchingThread implements Runnable {
              Component display;
       
              public SwitchingThread(Component display) {
                  this.display = display;
              }
       
              public void run() {
                  boolean changed = false;
       
                  while(!changed) {
                      LNFIndex++;
                      LNFIndex %= LNFString.length;
       
                      try {
                          UIManager.setLookAndFeel(LNFString[LNFIndex]);
                      } catch(UnsupportedLookAndFeelException e) {
                          changed = false;
                          e.printStackTrace();
                          continue;
                      } catch(Exception e) {
                          e.printStackTrace();
                          continue;
                      }
                      
                      changed = true;
                  }
                     
                  SwingUtilities.updateComponentTreeUI(display);
              }
          }
      }

      ----------------------------------------------------------------


      edmund.lou@eng 2000-10-13
      Swing Test Developer
      -------------------------------------

            amfowler Anne Fowler (Inactive)
            elousunw Edmund Lou (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: