AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

LookAndFeel problem

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits
View previous topic :: View next topic  
Author Message
Do
Guest





PostPosted: Sat Apr 16, 2005 3:44 pm    Post subject: LookAndFeel problem Reply with quote



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
Back to top
Richard Wheeldon
Guest





PostPosted: Sun Apr 17, 2005 6:53 pm    Post subject: Re: LookAndFeel problem Reply with quote



Do wrote:
Quote:
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

Back to top
Do
Guest





PostPosted: Tue Apr 19, 2005 10:17 am    Post subject: Re: LookAndFeel problem Reply with quote



Richard Wheeldon <richard (AT) rswheeldon (DOT) com> wrote

Quote:
Do wrote:
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




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

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java GUI Toolkits All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.