在Java应用程序中添加外观

时间:2010-03-15 05:09:42

标签: java look-and-feel netbeans6.5

我正在使用 NetBeans 6.5 IDE

我下载了一个外观和感觉jar文件,并通过调色板管理器添加了NetBeans。

如何在我的应用程序中使用它?

2 个答案:

答案 0 :(得分:3)

您可以按照此Sun教程了解setting the L&F in Java

  

即使程序的GUI可见,您也可以使用setLookAndFeel更改L& F.   要使现有组件反映新的L& F,请为每个顶级容器调用SwingUtilities updateComponentTreeUI方法。
  然后,您可能希望调整每个顶级容器的大小以反映其包含的组件的新大小。例如:

UIManager.setLookAndFeel(lnfName);
SwingUtilities.updateComponentTreeUI(frame);
frame.pack();

答案 1 :(得分:2)

感谢您的回复。 通过使用下面的代码,我们可以获得所有外观和感觉类名。

UIManager.LookAndFeelInfo[] lookAndFeelInfos = UIManager.getInstalledLookAndFeels();
    for (int i = 0; i < lookAndFeelInfos.length; i++) {
        UIManager.LookAndFeelInfo lookAndFeelInfo = lookAndFeelInfos[i];

        //
        // Get the name of the look and feel
        //
        String name = lookAndFeelInfo.getName();
        System.out.println("name = " + name);

        //
        // Get the implementation class for the look and feel
        //
        String className = lookAndFeelInfo.getClassName();
        System.out.println("className = " + className);
    }
相关问题