MOD*_*MOD 3 java swing jframe look-and-feel nimbus
我在项目中使用Nimbus Look and Feel.但是,尽管每个GUI JComponent都具有Nimbus的外观,但JFrame始终具有Windows外观.
JFrame如何拥有Nimbus外观和感觉?
编辑:操作系统:Windows XP
试试这个:
JFrame.setDefaultLookAndFeelDecorated(true); //before creating JFrames
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅教程中的如何设置外观.
import javax.swing.*;
class FrameLook {
public static void showFrame(String plaf) {
try {
UIManager.setLookAndFeel(plaf);
} catch(Exception e) {
e.printStackTrace();
}
JFrame f = new JFrame(plaf);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setSize(400,100);
f.setLocationByPlatform(true);
f.setDefaultLookAndFeelDecorated(true);
f.setVisible(true);
}
public static void main(String[] args) {
showFrame(UIManager.getSystemLookAndFeelClassName());
showFrame(UIManager.getCrossPlatformLookAndFeelClassName());
showFrame("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
}
Run Code Online (Sandbox Code Playgroud)
