Article View: borland.public.jbuilder.java.swing
Article #649null pointer while changing L & F
From: GEORGE
Date: Sat, 16 Apr 2005 01:08
Date: Sat, 16 Apr 2005 01:08
114 lines
4560 bytes
4560 bytes
I am using the code below to change the look and feel of my app using 3
radio buttons for Metal, Motif and Windows.
The L & F changes alright. But I get a null pointer exception along the
way. The stack trace is also shown below but I am unable to make much of
it. Any help would be appreciated.
TIA
George
------------------------------------------------------------------------------------------------
MY CODE
int laf = userPreferences.getInt("LOOK_AND_FEEL",
LookAndFeelPanel.METAL);
switch (laf) {
case LookAndFeelPanel.MOTIF:
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
// this.pack();
return;
case LookAndFeelPanel.WINDOWS:
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
// this.pack();
return;
default:
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
// this.pack();
----------------------------------------------------------------------------------------------
STACK TRACE
Exception occurred during event dispatching:
java.lang.NullPointerException
at
javax.swing.plaf.basic.BasicSplitPaneUI.getPreferredSize(BasicSplitPaneUI.java:1065)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1582)
at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:911)
at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:816)
at java.awt.GridBagLayout.preferredLayoutSize(GridBagLayout.java:636)
at java.awt.Container.preferredSize(Container.java:1558)
at java.awt.Container.getPreferredSize(Container.java:1543)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1584)
at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:911)
at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:816)
at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:1412)
at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:1372)
at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:712)
at java.awt.Container.layout(Container.java:1401)
at java.awt.Container.doLayout(Container.java:1390)
at java.awt.Container.validateTree(Container.java:1473)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validateTree(Container.java:1480)
at java.awt.Container.validate(Container.java:1448)
at
javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:379)
at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:113)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
at java.awt.Dialog$1.run(Dialog.java:515)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Technical Details
Message-ID:
<4260659e@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 111d45,d97b42cc813c1e29,start X-Google-Attributes: gid111d45,public X-Google-Language: ENGLISH,ASCII-7-bit From: "GEORGE" <geo@nowhere.net> Newsgroups: borland.public.jbuilder.java.swing Subject: null pointer while changing L & F Date: Fri, 15 Apr 2005 21:08:45 -0400 Lines: 117 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 70.21.173.47 Message-ID: <4260659e@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1113613726 70.21.173.47 (15 Apr 2005 18:08:46 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail