Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何安装/配置自定义Java外观?_Java_Swing_Properties_Installation_Look And Feel - Fatal编程技术网

如何安装/配置自定义Java外观?

如何安装/配置自定义Java外观?,java,swing,properties,installation,look-and-feel,Java,Swing,Properties,Installation,Look And Feel,我正在尝试安装海镜的外观和感觉。我想使用属性文件安装/配置LaF,但概述此过程的教程非常混乱 也就是说,任何人都可以提供一个关于使用属性文件安装/配置自定义LaF的简单分步指南吗?从他们的网站: 要使用Sea Glass外观,必须将其包含在pom.xml文件中,或者下载jar文件并将其包含在类路径中。有关更多详细信息,请参阅下载页面 要启用海镜外观,请在创建任何控件之前在应用程序中包括以下内容: try { UIManager.setLookAndFeel("com.seaglasslo

我正在尝试安装海镜的外观和感觉。我想使用属性文件安装/配置LaF,但概述此过程的教程非常混乱

也就是说,任何人都可以提供一个关于使用属性文件安装/配置自定义LaF的简单分步指南吗?

从他们的网站:

要使用Sea Glass外观,必须将其包含在pom.xml文件中,或者下载jar文件并将其包含在类路径中。有关更多详细信息,请参阅下载页面

要启用海镜外观,请在创建任何控件之前在应用程序中包括以下内容:

try {
    UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
} catch (Exception e) {
    e.printStackTrace();
}
我们还支持使用VM选项在命令行上设置用户界面

-Dswing.defaultlaf=com.seaglasslookandfeel.SeaGlassLookAndFeel

从NB IDE运行它我没有任何问题

源代码

import java.awt.*;
import javax.swing.*;
//import javax.swing.plaf.InsetsUIResource;

public class NimbusJPanelBackGround {

    public NimbusJPanelBackGround() {
        JFrame f = new JFrame();
        JButton btn = new JButton("  Whatever  ");
        JButton btn1 = new JButton("  Whatever  ");
        JPanel p = new JPanel();
        p.add(btn);
        //UIManager.getLookAndFeelDefaults().put("Button.contentMargins", new InsetsUIResource(0, 0, 0, 0));
        //SwingUtilities.updateComponentTreeUI(f);
        p.add(btn1);
        f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        f.add(p, BorderLayout.CENTER);
        f.setSize(200, 100);
        f.setLocation(150, 150);
        f.setVisible(true);
    }

    public static void main(String[] args) {

        /*try {
        for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) {
        if ("Nimbus".equals(laf.getName())) {
        UIManager.setLookAndFeel(laf.getClassName());
        UIManager.getLookAndFeelDefaults().put("Panel.background", Color.white);
        }
        }
        } catch (Exception e) {
        e.printStackTrace();
        }*/

        try {
            UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
        } catch (Exception e) {
            e.printStackTrace();
        }


        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                NimbusJPanelBackGround nimbusJPanelBackGround = new NimbusJPanelBackGround();
            }
        });
    }
}
编辑:


查看我的答案的通知中也没有要求用户信誉>10k,社区会将答案作为非答案删除:-)

以下是使用jar文件安装Sea Glass L&F的步骤(请注意,我使用eclipse,因此说明将在eclipse中)

  • LaF jar文件位于Maven存储库中
  • 将.jar文件放在项目中指定的文件夹中
  • 右键单击eclipse中的项目文件夹,转到“构建路径”,然后选择“配置构建路径”
  • 在“库”选项卡下,单击“添加外部Jar”并转到包含Jar文件的文件夹
  • 单击“确定”,然后在代码中转到
    公共静态void main(字符串[]args)
    并复制粘贴此代码段:

    try {
        UIManager.setLookAndFeel("com.seaglasslookandfeel.SeaGlassLookAndFeel");
    } catch (Exception e) {
        e.printStackTrace();
    }
    
  • 现在,L&F已应用。如果你有问题就问吧