当我在Linux平台上运行我的应用程序时,它抛出异常并且看不到框架/面板中的任何组件,而是显示灰色屏幕,当我们单击/移动鼠标指向组件上方时,将显示该组件。此外,我还有动态测试更新按钮,每次鼠标移动到按钮上方也会更新。
注意:同样的应用程序在Windows平台上运行良好。
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at javax.swing.plaf.basic.BasicButtonUI.getMinimumSize(BasicButtonUI.java:352)
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at javax.swing.JComponent.getMinimumSize(JComponent.java:1714)
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at java.awt.BorderLayout.minimumLayoutSize(BorderLayout.java:651)
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at java.awt.Container.minimumSize(Container.java:1651)
INFO | jvm 1 | main | 2013/01/21 15:14:23.995 | at java.awt.Container.getMinimumSize(Container.java:1636)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at javax.swing.JComponent.getMinimumSize(JComponent.java:1716)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.FlowLayout.minimumLayoutSize(FlowLayout.java:448)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.minimumSize(Container.java:1651)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.getMinimumSize(Container.java:1636)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at javax.swing.JComponent.getMinimumSize(JComponent.java:1716)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:1094)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:893)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:2052)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:2008)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:789)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.layout(Container.java:1421)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.doLayout(Container.java:1410)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1507)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1513)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1513)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1513)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validateTree(Container.java:1513)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.Container.validate(Container.java:1480)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:669)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:124)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue.access$000(EventQueue.java:85)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue$1.run(EventQueue.java:603)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue$1.run(EventQueue.java:601)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.security.AccessController.doPrivileged(Native Method)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventQueue.dispatchEvent(EventQueue.java:612)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
INFO | jvm 1 | main | 2013/01/21 15:14:23.996 | at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
答案 0 :(得分:0)
好的,让我们挖一下你的堆栈跟踪一段时间:
at javax.swing.plaf.basic.BasicButtonUI.getMinimumSize(BasicButtonUI.java:352)
让我们看看那里的代码:
public Dimension getMinimumSize(JComponent c) {
Dimension d = getPreferredSize(c);
View v = (View) c.getClientProperty(BasicHTML.propertyKey);
if (v != null) {
d.width -= v.getPreferredSpan(View.X_AXIS) - v.getMinimumSpan(View.X_AXIS); // Line 352
}
return d;
}
好的,所以NullPointerException
来自getPreferredSize(JComponent c)
,返回null
。
所以最后,你的按钮包含额外的组件,或者在Linux上选择的外观和感觉返回null
值(无论出于何种原因,不可能找到如此少的细节)。