Java Swing Look and Feel useCrossPlatformLookAndFeel(Component object)

Here you can find the source of useCrossPlatformLookAndFeel(Component object)

Description

use Cross Platform Look And Feel

License

Open Source License

Declaration

public static void useCrossPlatformLookAndFeel(Component object) 

Method Source Code


//package com.java2s;
/*//w  w  w.  ja va  2  s .com
Open Auto Trading : A fully automatic equities trading platform with machine learning capabilities
Copyright (C) 2015 AnyObject Ltd.
    
This program 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.
    
This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.awt.*;

import javax.swing.*;

public class Main {
    public static void useCrossPlatformLookAndFeel(Component object) {
        String laf;
        boolean useNative = false;

        if (useNative) {
            laf = UIManager.getSystemLookAndFeelClassName();
        } else {
            laf = UIManager.getCrossPlatformLookAndFeelClassName();
        }

        try {
            UIManager.setLookAndFeel(laf);
            SwingUtilities.updateComponentTreeUI(object);
        } catch (Exception e) {
            System.err.println("Couldn't use the " + laf + "look and feel: " + e);
        }
    }
}

Related

  1. setWindowsLookLike(Window window)
  2. supportsDarkLookAndFeel()
  3. trySetNimbusLookAndFeel()
  4. tryToSetSystemLookAndFeel()
  5. tweakLookAndFeel()
  6. usingAppleLAF()