Unable to use Sea Glass LAF for the Java application

流过昼夜 提交于 2021-02-11 05:01:15

问题


I am trying to use the Sea Glass LAF for a Java application but it gives the Class Not Found Exception (in Windows using JDK 8). I added the seaglass-0.1.7.3 jar file to the libraries folder and added it to build path. I also added import com.seaglasslookandfeel.*; to the code but it is shown as an unused import.

Below is my code:

public static void main( String[] args )
{
    EventQueue.invokeLater( new Runnable()
    {
        @Override
        public void run() 
        {
            try
            {
                UIManager.setLookAndFeel( "com.seaglasslookandfeel.SeaGlassLookAndFeel" );
                setHomeWindow( new HomeWindow() );
                window.getFrame().setVisible( true );

            }
            catch ( Exception e )
            {
                e.printStackTrace();
            }
        }
    } );
}

How can I solve this and use Seaglass? Any help is much appreciated.


回答1:


I tried the following code and it works fine. I downloaded the seaglass jar from this link: http://www.java2s.com/Code/Jar/s/Downloadseaglasslookandfeel02jar.htm

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.UIManager;

public class HomeWindow extends JFrame{

    public HomeWindow() {
        setTitle("look and feel demo");
        setSize(800, 600);
        setVisible(true);       
    }

        public static void main( String[] args )
        {
            EventQueue.invokeLater( new Runnable()
            {
                @Override
                public void run() 
                {
                    try
                    {
                        UIManager.setLookAndFeel( "com.seaglasslookandfeel.SeaGlassLookAndFeel" );
                         new HomeWindow();                      

                    }
                    catch ( Exception e )
                    {
                        e.printStackTrace();
                    }
                }
            } );
        }


}



回答2:


It appears to be the case that the SynthUI pluggable-look-and-feel classes (on which the Sea Glass LAF depends) were migrated from the sun.* package space into javax.* as of Java 7. As mentioned in a comment by @aurelianr, a newer Sea Glass JAR that has been compiled against JDK >= 7 should fix your issue.




回答3:


@thewmo and @aurelianr are right. You may find the newest version here: https://mvnrepository.com/artifact/com.seaglasslookandfeel/seaglasslookandfeel

If you want to do it using Maven or simple downloading the jar file



来源:https://stackoverflow.com/questions/38690638/unable-to-use-sea-glass-laf-for-the-java-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!