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

Nimbus L&F : getting java.lang.ClassNotFoundException: sun.swing.plaf.nimbus.NimbusLookAndFeel when

    Details

    • Subcomponent:
    • Resolved In Build:
      b12
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      http://monaco.sfbay.sun.com/detail.jsf?cr=6616742 moved nimbus from sun.swing.plaf.nimbus to com.sun.swing.plaf.nimbus. This works fine when pass -Dswing.defaultlaf=com.sun.swing.plaf.nimbus.NimbusLookAndFeel as arguments. When we try to change the lookAndFeel programmically then the changes will not effect. This is reproducable only on pit build i,e after the fix. This is a blocker for our test execution , where we change the lookandfeel programmically.

      Step to reproduce:
      ---------------------
      1) Run the below testcase.
      2) Try to changing the look&feel from the menu. When you choose Nimbus , if you see the exception then the bug is reproduced.


      ---------- testcase ----------
      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;

      public class NimbusLookAndFeelIsNotApplied implements java.awt.event.ItemListener {
      JFrame frame = null;
      JMenu lookAndFeelMenu = null;
      JMenuBar menuBar = null;

      NimbusLookAndFeelIsNotApplied(){
      frame = new JFrame();
      UIManager.LookAndFeelInfo[] laf = UIManager.getInstalledLookAndFeels();
      JMenu lafMenu = new JMenu("Look And Feel");
      lafMenu.setMnemonic('k');
      ButtonGroup group = new ButtonGroup();
      LookAndFeel defaultLAF = UIManager.getLookAndFeel();
      for(int i=0; i<laf.length; i++) {
      JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(laf[i].getName());
      menuItem.setActionCommand(laf[i].getClassName());
      menuItem.addItemListener(this);
      if(laf[i].getName().equals(defaultLAF.getName())) {
      menuItem.setSelected(true);
      }
      group.add(menuItem);
      lafMenu.add(menuItem);
      }
      menuBar = new JMenuBar();
      menuBar.add(lafMenu);
      frame.setJMenuBar(menuBar);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(300,300);
      frame.setVisible(true);
      }

      public void itemStateChanged(java.awt.event.ItemEvent ie){
      if(ie.getStateChange() == ItemEvent.SELECTED){
      try {
      JMenuItem menuItem = (JMenuItem) ie.getItem();
      UIManager.setLookAndFeel(menuItem.getActionCommand());
      Component parent = SwingUtilities.windowForComponent(this.frame);
      if(parent == null) {
      parent = this.frame;
      }
      SwingUtilities.updateComponentTreeUI(parent);
      } catch (Exception e) {
      System.err.println("Error: Cannot set this Look And Feel " + e);
      }
      }
      }


      public static void main(String []args){
      javax.swing.SwingUtilities.invokeLater(new Runnable(){
      public void run(){
      new NimbusLookAndFeelIsNotApplied();
      }
      });
      }
      }
      ------------------------------
      The correct new package for Nimbus is "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" not "com.sun.swing..."

        Attachments

          Activity

            People

            • Assignee:
              jasper Jasper Potts
              Reporter:
              lpremkumsunw Lawrence Premkumar1 (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: