Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LookAndFeel changing program will not work?

 
Laurence Turpin
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Laurence Turpin
Greenhorn
Posts: 19
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic