 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Do Guest
|
Posted: Sat Apr 16, 2005 3:44 pm Post subject: LookAndFeel problem |
|
|
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
|
Posted: Sun Apr 17, 2005 6:53 pm Post subject: Re: LookAndFeel problem |
|
|
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
|
Posted: Tue Apr 19, 2005 10:17 am Post subject: Re: LookAndFeel problem |
|
|
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 |
|
 |
|
|
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
|
|