Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / April 2005

Tip: Looking for answers? Try searching our database.

LookAndFeel problem

Thread view: 
Do - 16 Apr 2005 16:44 GMT
Hello,

I have a problem with changing the look and feel while running my java
application: When I try to change the look and feel while runtime,
following exeption occures:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
   at com.sun.java.swing.plaf.windows.WindowsTableHeaderUI$XPDefaultRenderer.paint(Unknown
Source)
   at javax.swing.CellRendererPane.paintComponent(Unknown Source)
   at javax.swing.plaf.basic.BasicTableHeaderUI.paintCell(Unknown
Source)
   at javax.swing.plaf.basic.BasicTableHeaderUI.paint(Unknown Source)

and so on...

Here is the source code for changing my look and feel:

UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) rbmi2
               .getClientProperty ("lnf name");
           try
           {
             UIManager.setLookAndFeel (info.getClassName ());
             SwingUtilities.updateComponentTreeUI (mainWin);
           }
           catch (Exception e)
           {
             System.err.println (" unable to set UI "
                 + e.getMessage ());
           }

Is it a bug, because of the exception in WindowsTableHeader...?

Thanks a lot in advance for answers!

Greets,

Do
Richard Wheeldon - 17 Apr 2005 19:51 GMT
> UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) rbmi2
>                 .getClientProperty ("lnf name");
>             try
>             {
>               UIManager.setLookAndFeel (info.getClassName ());
>               SwingUtilities.updateComponentTreeUI (mainWin);

UIManager is looking for a LookAndFeel class not a LookAndFeelInfo
one. That's possibly the cause of the problem,

Richard
Do - 19 Apr 2005 11:17 GMT
> > UIManager.LookAndFeelInfo info = (UIManager.LookAndFeelInfo) rbmi2
> >                 .getClientProperty ("lnf name");
[quoted text clipped - 7 lines]
>
> Richard

Hello Richard,

I use the LookAndFeelInfo for creating a menu to enable the selection
of all installed LookAndFeels. The strange thing is, that sometimes it
works fine, but sometimes, when I start the application in Windows
style and try to change in another style there occures this execption
in the TableHeader (WindowsTableHeaderUI$XPDefaultRenderer). I think
that the problem is not the way I set the look and feel
(UIManager.setLookAndFeel (info.getClassName () ), it must be
somethings else... It works fine, except the exception in the
TableHeader...

Following the source for the menu:

   UIManager.LookAndFeelInfo[] lnfs = UIManager
       .getInstalledLookAndFeels ();
   for (int i = 0; i < lnfs.length; i++)
   {
     JRadioButtonMenuItem rbmi = new JRadioButtonMenuItem (lnfs[i]
         .getName ());
     lookFeelMenu.add (rbmi);
     rbmi.setSelected (UIManager.getLookAndFeel ().getName ().equals
(
         lnfs[i].getName ()));
     rbmi.putClientProperty ("lnf name", lnfs[i]);
     rbmi.addItemListener (new ItemListener ()
     {
       public void itemStateChanged (ItemEvent ie)
       {
         JRadioButtonMenuItem rbmi2 = (JRadioButtonMenuItem) ie
             .getSource ();

         if (rbmi2.isSelected ())
         {
           UIManager.LookAndFeelInfo info =
(UIManager.LookAndFeelInfo) rbmi2
               .getClientProperty ("lnf name");
           try
           {
             UIManager.setLookAndFeel (info.getClassName ().toString
());
             SwingUtilities.updateComponentTreeUI (mainWin);
           }
           catch (Exception e)
           {
             System.err.println (e.getMessage ());
           }
         }
       }
     });
     lnfGroup.add (rbmi);
   }

Any suggestions for this problem?

Thanks a lot!  Do


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.