如何在swing应用程序中使用第三方主题?

时间:2010-04-27 09:17:51

标签: java eclipse swing jar

我想在我的摇摆应用中使用一些第三方主题(例如synthetica http://www.javasoft.de/synthetica/themes/)。我正在使用eclipse ide,获取了主题的jar文件并在我的代码中进行了以下修改(根据主题的自述文件)

try 
  {      
   UIManager.setLookAndFeel(new SyntheticaBlackMoonLookAndFeel());
  } 
  catch (Exception e) 
  {
   e.printStackTrace();
  }

但在此修改后,它显示以下错误

 The type de.javasoft.plaf.synthetica.SyntheticaLookAndFeel cannot be resolved. It is indirectly referenced from required .class files
这是什么意思?我尝试在网上搜索,但无法找到任何有用的答案

自述文件的内容:

System Requirements
===================

Java SE 5 (JRE 1.5.0) or above
Synthetica V2.2.0 or above

Integration
===========

1. Ensure that your classpath contains all Synthetica libraries (including
   Synthetica's core library 'synthetica.jar').

2. Enable the Synthetica Look and Feel at startup time in your application:

    import de.javasoft.plaf.synthetica.SyntheticaBlackMoonLookAndFeel;

    try 
    {
      UIManager.setLookAndFeel(new SyntheticaBlackMoonLookAndFeel());
    } 
    catch (Exception e) 
    {
      e.printStackTrace();
    }    

3 个答案:

答案 0 :(得分:2)

这意味着您缺少依赖类。如果你看一下要求,它还需要“Synthetica Standard Look and Feel”

您可以下载here

答案 1 :(得分:1)

如果您已下载 .jar -file,则需要将其添加到eclipse中的构建路径中。

即。如果您在eclipse项目中有一个目录 lib ,您可以在其中放置 .jar 文件,然后右键单击您的jar文件并选择 Build Path < / em>然后添加到构建路径

答案 2 :(得分:0)

我知道问题可能已经解决,因为这是一篇非常古老的帖子,但是这可能会影响其他当前用户(比如我自己):

  • 首先,您必须首先添加Synthetica.jar然后添加主题。要下载Synthetica.jar,请访问此链接:jyloo.com/synthetica/download。要下载主题,请尝试jyloo.com/synthetica/themes
  • 右键单击您的项目,然后单击“属性”
  • 在Java Build Path上,选择第三个选项卡,然后单击“添加JAR”或“添加外部JAR ...”并找到.jar文件并单击“打开”
  • 点击“确定”并启用主题,您可以使用以下代码:

    try {    
    UIManager.setLookAndFeel(new SyntheticaBlueMoonLookAndFeel());  
    }  catch (Exception e) {      
    e.printStackTrace();    
    }