Java Swing Look and Feel getLafClassName(String lafName)

Here you can find the source of getLafClassName(String lafName)

Description

Returns the class name of the LookAndFile class with the specified name, or null if no such class if found.

License

Open Source License

Parameter

Parameter Description
lafName the user name for the look and feel (e.g. Metal)

Return

the class name of the implementing class if found, otherwise null

Declaration

public static String getLafClassName(String lafName) 

Method Source Code

//package com.java2s;
/*/*from www  .  j a v  a  2 s  . c om*/
 * Copyright ? Mihai Borobocea 2009, 2010
 * 
 * This file is part of SimpleSwing.
 * 
 * SimpleSwing is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * SimpleSwing is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with SimpleSwing.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */

import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

public class Main {
    private static final LookAndFeelInfo[] availableLookAndFeels = UIManager.getInstalledLookAndFeels();

    /**
     * Returns the class name of the LookAndFile class with the specified name,
     * or null if no such class if found.
     * 
     * @param lafName
     *            the user name for the look and feel (e.g. Metal)
     * @return the class name of the implementing class if found, otherwise null
     */
    public static String getLafClassName(String lafName) {
        if (lafName == null)
            return null;

        for (LookAndFeelInfo lafInfo : availableLookAndFeels)
            if (lafName.equalsIgnoreCase(lafInfo.getName()))
                return lafInfo.getClassName();

        return null;
    }
}

Related

  1. fixLnF()
  2. getAvailableLookAndFeels()
  3. getAvailableLookAndFeels()
  4. getInstalledLookAndFeels()
  5. getLAF(int lafNumber)
  6. getLookAndFeel(final String displayName)
  7. getLookAndFeel(String name)
  8. getLookAndFeelInfo()
  9. getLookAndFeelToSave()