こんにちは、ユーザーがルック アンド フィールを変更できるインターフェイスがあります。インターフェースは次のとおりです。
http://www.hostingpics.net/viewer.php?id=579250themesApp.jpg
各ボタンのコード:
//The JDesktop Frame contains all the Internal Frames
JDesktop p = new JDesktop();
try {
UIManager.setLookAndFeel( new javax.swing.plaf.metal.MetalLookAndFeel());
SwingUtilities.updateComponentTreeUI(p);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(paramApparence.class.getName()).log(Level.SEVERE, null, ex);
}
ボタンごとにルック アンド フィールのみを変更します (Metal/Nimbus など)。
ボタンをクリックしてルックアンドフィールを変更すると、次のようになります。
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
完全なスタック トレースは次のとおりです。
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:217)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286)
at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1012)
at javax.swing.JComponent.getFontMetrics(JComponent.java:1624)
at sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:125)
at javax.swing.plaf.synth.SynthMenuItemLayoutHelper.<init>(SynthMenuItemLayoutHelper.java:119)
at javax.swing.plaf.synth.SynthGraphicsUtils.paint(SynthGraphicsUtils.java:498)
at javax.swing.plaf.synth.SynthMenuUI.paint(SynthMenuUI.java:283)
at javax.swing.plaf.synth.SynthMenuUI.update(SynthMenuUI.java:248)
at javax.swing.JComponent.paintComponent(JComponent.java:778)
at javax.swing.JComponent.paint(JComponent.java:1054)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5221)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)
at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
at javax.swing.JComponent._paintImmediately(JComponent.java:5169)
at javax.swing.JComponent.paintImmediately(JComponent.java:4980)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:217)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286)
at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1012)
at javax.swing.JComponent.getFontMetrics(JComponent.java:1624)
at sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:126)
at javax.swing.plaf.synth.SynthMenuItemLayoutHelper.<init>(SynthMenuItemLayoutHelper.java:119)
at javax.swing.plaf.synth.SynthGraphicsUtils.paint(SynthGraphicsUtils.java:498)
at javax.swing.plaf.synth.SynthMenuItemUI.paint(SynthMenuItemUI.java:283)
at javax.swing.plaf.synth.SynthMenuItemUI.update(SynthMenuItemUI.java:247)
at javax.swing.JComponent.paintComponent(JComponent.java:778)
at javax.swing.JComponent.paint(JComponent.java:1054)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5221)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)
at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
at javax.swing.JComponent._paintImmediately(JComponent.java:5169)
at javax.swing.JComponent.paintImmediately(JComponent.java:4980)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.font.FontDesignMetrics$MetricsKey.init(FontDesignMetrics.java:217)
at sun.font.FontDesignMetrics.getMetrics(FontDesignMetrics.java:286)
at sun.swing.SwingUtilities2.getFontMetrics(SwingUtilities2.java:1012)
at javax.swing.JComponent.getFontMetrics(JComponent.java:1624)
at sun.swing.MenuItemLayoutHelper.reset(MenuItemLayoutHelper.java:126)
at javax.swing.plaf.synth.SynthMenuItemLayoutHelper.<init>(SynthMenuItemLayoutHelper.java:119)
at javax.swing.plaf.synth.SynthGraphicsUtils.paint(SynthGraphicsUtils.java:498)
at javax.swing.plaf.synth.SynthMenuItemUI.paint(SynthMenuItemUI.java:283)
at javax.swing.plaf.synth.SynthMenuItemUI.update(SynthMenuItemUI.java:247)
at javax.swing.JComponent.paintComponent(JComponent.java:778)
at javax.swing.JComponent.paint(JComponent.java:1054)
at javax.swing.JComponent.paintChildren(JComponent.java:887)
at javax.swing.JComponent.paint(JComponent.java:1063)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5221)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:295)
at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
at javax.swing.JComponent._paintImmediately(JComponent.java:5169)
at javax.swing.JComponent.paintImmediately(JComponent.java:4980)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:770)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677)
at javax.swing.RepaintManager.access$700(RepaintManager.java:59)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)