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

UIManager.LookAndFeelInfo.getName() != UIManager.getLookAndFeel.getName()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.2.0
    • 1.1.5, 1.2.0
    • client-libs
    • 1.2beta4
    • generic
    • generic
    • Not verified



      Name: rk38400 Date: 05/14/98


      The LookAndFeel names returned by
      UIManager.LookAndFeelInfo.getName() and
      UIManager.getLookAndFeel().getName() are different.
      I would like to get a list of available LAF's and
      select the default one from that list.
      Code snippet:

      private String[] getLAFNames() {

          UIManager.LookAndFeelInfo[] lafInfos =
            UIManager.getInstalledLookAndFeels();
          String[] LAFNames = new String[lafInfos.length];
          int i;
          for( i = 0; i < lafInfos.length; i++ ){
      LAFNames[i] = lafInfos[i].getName();
          }
          return( LAFNames );
        }

        private void addLAFRadioMenuAndSetLAF( JMenu menu ){
          String[] lafNames = getLAFNames();
          JRadioButtonMenuItem[] lafRadios;
          ButtonGroup lafGroup = new ButtonGroup();
          LookAndFeel defaultLAF = UIManager.getLookAndFeel();
          String defaultLAFName = defaultLAF.getName();

          if( defaultLAF == null ){
            lafRadios = new JRadioButtonMenuItem[lafNames.length+1];
            // Add Radio for the default selection
          }else{
            lafRadios = new JRadioButtonMenuItem[lafNames.length];
          }
          int i;
          for( i = 0; i < lafNames.length; i++ ){
            lafRadios[i] = new JRadioButtonMenuItem( lafNames[i] );
            lafGroup.add( lafRadios[i] );
            menu.add( lafRadios[i] );
      // Great, it gives different names from
      // UIManager.LookAndFeelInfo.getName() and
      // UIManager.getLookAndFeel.getName(), can't do:
      // if ( lafNames[i].equals(defaultLAFName)) lafRadios[i].setSelected(true);
            System.out.println( "'"+lafNames[i]+"'" + " " + "'"+defaultLAFName+"'" );
          }


        }

      Output using swing-1.0.1:

      'Metal' 'Metal Look and Feel'
      'CDE/Motif' 'Metal Look and Feel'
      'Windows' 'Metal Look and Feel'


      PS. This is my second bug report today. I am entitled
      to a T-shirt now, right?
      (Review ID: 26608)
      ======================================================================

            sswingtrsunw Swingtraq Swingtraq (Inactive)
            rkarsunw Ralph Kar (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: