This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes LookAndFeel changing program will not work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "LookAndFeel changing program will not work?" Watch "LookAndFeel changing program will not work?" New topic
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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: 4523
    
    5

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?
 
Similar Threads
Can I Use JLayeredPane
I need help with Look&Feel .
WhenI try to run this applet it gives an error??? why??need help!
Look and Feel
Problem With validate()