Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

JDK换成了1.5,搞了一个JTextArea,在里面输入英文,没有一点问题,输入中文是抛出异常了。

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at java.util.Hashtable.get(Hashtable.java:336)
	at javax.swing.KeyboardManager.registerMenuBar(KeyboardManager.java:263)
	at javax.swing.JMenuBar.addNotify(JMenuBar.java:679)
	at java.awt.Container.addNotify(Container.java:2500)
	at javax.swing.JComponent.addNotify(JComponent.java:4478)
	at javax.swing.plaf.metal.MetalTitlePane.addNotify(MetalTitlePane.java:223)
	at java.awt.Container.addNotify(Container.java:2500)
	at javax.swing.JComponent.addNotify(JComponent.java:4478)
	at java.awt.Container.addNotify(Container.java:2500)
	at javax.swing.JComponent.addNotify(JComponent.java:4478)
	at javax.swing.JRootPane.addNotify(JRootPane.java:680)
	at java.awt.Container.addNotify(Container.java:2500)
	at java.awt.Window.addNotify(Window.java:467)
	at java.awt.Frame.addNotify(Frame.java:501)
	at java.awt.Window.pack(Window.java:485)
	at sun.awt.im.CompositionArea.<init>(CompositionArea.java:71)
	at sun.awt.im.CompositionAreaHandler.createCompositionArea(CompositionAreaHandler.java:56)
	at sun.awt.im.CompositionAreaHandler.inputMethodTextChanged(CompositionAreaHandler.java:169)
	at sun.awt.im.CompositionAreaHandler.processInputMethodEvent(CompositionAreaHandler.java:144)
	at sun.awt.im.InputMethodContext.dispatchEvent(InputMethodContext.java:175)
	at java.awt.Component.dispatchEventImpl(Component.java:3919)
	at java.awt.Container.dispatchEventImpl(Container.java:2024)
	at java.awt.Component.dispatchEvent(Component.java:3819)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
	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)

 解决办法很简单,去掉程序中的JFrame.setDefaultLookAndFeelDecorated(true);

你可能感兴趣的:(java,jdk,thread,swing,sun)