在java Swing编程中,作为窗体,我们经常编写类继承JFrame,在main方法中进行加载,如下

JFrame.setDefaultLookAndFeelDecorated_swing


有一种方法,不用继承JFrame也可以弹窗,代码如下

JFrame.setDefaultLookAndFeelDecorated_swing_02


但是这个跟我们今天的setDefaultLookAndFeelDecorated有什么关系呢,这个设置,必须在new 对象前进行调用,才有装饰效果,如下

JFrame.setDefaultLookAndFeelDecorated_java_03


说白了,就是有一些样式,这个可以进行更改。

//        1、Metal风格 (默认)
//        String lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";
//        UIManager.setLookAndFeel(lookAndFeel);

//        2、Windows风格
//        String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
//        UIManager.setLookAndFeel(lookAndFeel);

//        3、Windows Classic风格
//        String lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel";
//        UIManager.setLookAndFeel(lookAndFeel);

//        4、Motif风格
//        String lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
//        UIManager.setLookAndFeel(lookAndFeel);

//        5、Mac风格 (需要在相关的操作系统上方可实现)
//        String lookAndFeel = "com.sun.java.swing.plaf.mac.MacLookAndFeel";
//        UIManager.setLookAndFeel(lookAndFeel);

//        6、GTK风格 (需要在相关的操作系统上方可实现)
//        String lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
//        UIManager.setLookAndFeel(lookAndFeel);

//        7、可跨平台的默认风格
//        String lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
//        UIManager.setLookAndFeel(lookAndFeel);

//        8、当前系统的风格
        String lookAndFeel = UIManager.getSystemLookAndFeelClassName();
        UIManager.setLookAndFeel(lookAndFeel);