Java中Swing的窗体怎么弄才好看
发布网友
发布时间:2022-05-16 01:58
我来回答
共3个回答
热心网友
时间:2023-10-08 22:58
String windows="com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
UIManager.setLookAndFeel(windows);
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");//Nimbus风格,新出来的外观,jdk6 update10版本以后的才会出现
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());//当前系统风格
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");//Motif风格,外观接近windows经典,但宽宽大大,而且不是黑灰主色,而是蓝黑
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());//跨平台的Java界面风格,不太明白这种说法
//UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");//windows风格
//UIManager.setLookAndFeel("javax.swing.plaf.windows.WindowsLookAndFeel");//windows风格
//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");//java风格
//UIManager.setLookAndFeel("com.apple.mrj.swing.MacLookAndFeel");
热心网友
时间:2023-10-08 22:58
public class MainClass extends JFrame {
JFrame.setDefaultLookAndFeelDecorated(true);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(new SubstanceModerateLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
MainClass main = new MainClass();
main.setsize(300, 300);
main.setvisible(true);
}
需要导入substance.jar包, SubstanceModerateLookAndFeel()为其中的一个风格
热心网友
时间:2023-10-08 22:58
javaSwing控件全部是绘制的,不但耗内存,并且跟操作系统不搭配,建议使用swt,其使用jni直接调用操作系统控件资源,比如eclipse就是swt编写的,很好看,尤其是windos7.