| Author |
LookAndFeel changing program will not work?
|
Laurence Turpin
Greenhorn
Joined: May 21, 2012
Posts: 19
|
|
Hello,
I am running Java 6 on a Windows 7 PC.
I am using Eclipse Indigo to run my program.
My program has 2 files:
ToolbarFrame1.java
LnFListener.java
The files compile ok.
When run and I try to change the look and feel I get the following errors
-------------------------------------------------------------------------------------------
LookAndFeel class not found: com.apple.mrj.swing.MacLookAndFeel
LookAndFeel class not found: com.sun.java.swing.plaf.motif.Motif.MotifLookAndFeel
LookAndFeel class not found: com.sun.java.swing.plaf.windows.WindowsLookAndFeel
------------------------------------------------------------------------------------------
Below are the contents of the two files.
--------------------------------------------------------------------------------
ToolBarFrame1.java
----------------------------------------------------------------------------------------
------------------------------------------------------------------------------
LnFListener. java
-------------------------------------------------------------------------------
I would be grateful for any helpful suggestions.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
Welcome to the Ranch!
The errors mean that the look & feel classes that you are trying to use do not exist on your system.
I'm not surprised that "com.apple.mrj.swing.MacLookAndFeel" does not exist, because you're running this on a Windows 7 system and not on an Apple Mac.
Note that class UIManager has a method named getInstalledLookAndFeels() that gives you information about what look & feels are available on your system. You could use that to check which ones you can use, instead of using hard-coded names of look & feels that apparently don't exist on your system.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Laurence Turpin
Greenhorn
Joined: May 21, 2012
Posts: 19
|
|
Thank you for your reply.
You are right about the mac LookAndFeel not working on windows.
I changed the mac LookAndFeel to nimbus
I also made a mistake with the motif LookAndFeel
Instead of :
com.sun.java.swing.plaf.motif.Motif.MotifLookAndFeel
It should be:
com.sun.java.swing.plaf.motif.MotifLookAndFeel
Now that I have made those changes it now all works.
Thank you again for your help
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
Laurence Turpin wrote:Instead of :
com.sun.java.swing.plaf.motif.Motif.MotifLookAndFeel
It should be:
com.sun.java.swing.plaf.motif.MotifLookAndFeel
You shouldn't be using com.sun.*... classes at all, as they are subject to change or removal. Jesper already told you how to get the list of installed LaFs.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
 |
|
|
subject: LookAndFeel changing program will not work?
|
|
|