私は、さまざまな方法でOracleデータベースを管理する企業向けのアプリケーション を開発しています。 プログラムはJava、NetBeansにあり、かなり大きくなっています。 私はそれが非常によく書かれていると言うではないだろうが、私は頻繁に はバック古い不正なコードを取得し、 私ができるように読みやすく、OOPとしてそれを作ってみます。Java - 開始時にNullPointerExceptionが発生しました。スイングバグか実装不良?
私は プログラムを起動したときに10回のうち1が、私は次の例外を取得していますことに気付きました:( プログラムが起動かかわらず、右の作品、でもこれらの時間)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.plaf.synth.SynthLabelUI.getMinimumSize(SynthLabelUI.java:199)
at javax.swing.JComponent.getMinimumSize(JComponent.java:1702)
at javax.swing.GroupLayout$ComponentSpring.calculateNonlinkedMinimumSize(GroupLayout.java:2933)
at javax.swing.GroupLayout$ComponentSpring.calculateMinimumSize(GroupLayout.java:2897)
at javax.swing.GroupLayout$Spring.getMinimumSize(GroupLayout.java:1315)
at javax.swing.GroupLayout$ComponentSpring.calculatePreferredSize(GroupLayout.java:2904)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1593)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1590)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1593)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1590)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1590)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout.calculateAutopadding(GroupLayout.java:1050)
at javax.swing.GroupLayout.prepare(GroupLayout.java:1037)
at javax.swing.GroupLayout.preferredLayoutSize(GroupLayout.java:857)
at java.awt.Container.preferredSize(Container.java:1599)
at java.awt.Container.getPreferredSize(Container.java:1584)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1624)
at javax.swing.GroupLayout$ComponentSpring.calculateNonlinkedPreferredSize(GroupLayout.java:2944)
at javax.swing.GroupLayout$ComponentSpring.calculateNonlinkedMinimumSize(GroupLayout.java:2930)
at javax.swing.GroupLayout$ComponentSpring.calculateMinimumSize(GroupLayout.java:2897)
at javax.swing.GroupLayout$Spring.getMinimumSize(GroupLayout.java:1315)
at javax.swing.GroupLayout$ComponentSpring.calculatePreferredSize(GroupLayout.java:2904)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1593)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$Group.getSpringSize(GroupLayout.java:1604)
at javax.swing.GroupLayout$Group.calculateSize(GroupLayout.java:1588)
at javax.swing.GroupLayout$Group.calculatePreferredSize(GroupLayout.java:1568)
at javax.swing.GroupLayout$Spring.getPreferredSize(GroupLayout.java:1325)
at javax.swing.GroupLayout$SequentialGroup.setValidSize(GroupLayout.java:1972)
at javax.swing.GroupLayout$Group.setSize(GroupLayout.java:1553)
at javax.swing.GroupLayout.calculateAutopadding(GroupLayout.java:1058)
at javax.swing.GroupLayout.layoutContainer(GroupLayout.java:897)
at java.awt.Container.layout(Container.java:1421)
at java.awt.Container.doLayout(Container.java:1410)
at java.awt.Container.validateTree(Container.java:1507)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validateTree(Container.java:1513)
at java.awt.Container.validate(Container.java:1480)
at java.awt.Window.dispatchEventImpl(Window.java:2473)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
私はそれがスイングバグだと仮定しています。私の実装で問題になることはありますか? なぜそれは10回のうち1回起こっていますが、必ずしもそうではありませんか? これを避けるために何かできますか?
あなたはEDTのGUIを起動しますか? – willcodejavaforfood
@ willcodejavaforfood:良い点。 GUI操作が(SWTのような)イベントディスパッチスレッドの外で実行される場合、スウィングは例外をスローするべきであるとの私の意見です。例外を投げないことによって、彼らは最小の驚きの原則に違反して自分自身を据えています。 :) –
@Adam Paynter IMO Swingはスレッドに敵対的であってはなりません。しかし、それは今ではそれほど多くのことはできません。 –