look and feel


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: look and feel

Hybrid View

  1. #1
    Join Date
    Mar 2005
    Location
    UK, London
    Posts
    150

    look and feel

    Hi every one, does any one know how I can implement the java look and feel of metal.

    I have the following code but it doesnt seem to do any thing.

    Code:
      try {
          UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } catch(Exception e) {
          System.out.println("Error setting Motif LAF: " + e);
        } {
    it works fine when I use motif. Any help would be greatly appreciated.

  2. #2
    Join Date
    Oct 2005
    Posts
    1
    You might try this. First get all of the look and feels supported, and then try them out to see.

    Code:
        
        private void setLook()
        {
            UIManager.LookAndFeelInfo looks[] = 
            Manager.getInstalledLookAndFeels();
            try
            {
                UIManager.setLookAndFeel(looks[3].getClassName());
                SwingUtilities.updateComponentTreeUI(this);
            }
            catch(InstantiationException ie)
            {
            }
            catch(ClassNotFoundException cnf_e)
            {
            }
            catch(IllegalAccessException ia_e)
            {
            }
            catch(UnsupportedLookAndFeelException ulf_e)
            {
            }
            catch(ArrayIndexOutOfBoundsException aoob_e)
            {
            }
            finally
            {
                this.setDefaultLookAndFeelDecorated(true);
            }
        }
    What this does is manually selects the look and feel from all installed look and feels. It could be that the look you are looking for is not installed.

    Rich Gomez

  3. #3
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    The javax.swing.plaf.metal "package description" says:

    Provides user interface objects built according to the Java look and feel (once codenamed Metal), which is the default look and feel.

    These classes are designed to be used while the corresponding LookAndFeel class has been installed (UIManager.setLookAndFeel(new XXXLookAndFeel())). Using them while a different LookAndFeel is installed may produce unexpected results, including exceptions. Additionally, changing the LookAndFeel maintained by the UIManager without updating the corresponding ComponentUI of any JComponents may also produce unexpected results, such as the wrong colors showing up, and is generally not encouraged
    Do these "unexpected results" sound to you like the behavior you've been seeing?

    Is your constructor correct? The UIManager.setLookAndFeel() call in the quoted passage looks different than the one you've provided ...
    Last edited by nspils; 10-04-2005 at 08:42 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center