當我重繪()的面板,在這裏我把我的JLabel上,我得到的錯誤,但它仍然有效。我試着把panel.repaint();代碼在try語句中,並沒有幫助。任何其他人有JPanels重繪()的問題?呼叫重繪()對於JPanels
錯誤信息(從評論複製):
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: No such child: 21
at java.awt.Container.getComponent(Unknown Source)
at javax.swing.JComponent.rectangleIsObscured(Unknown Source)
at javax.swing.JComponent.paint(Unknown Source)
at javax.swing.JComponent.paintToOffscreen(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source)
at javax.swing.RepaintManager$PaintManager.paint(Unknown Source))
你知道錯誤是什麼嗎? – 2012-07-18 23:35:44
有什麼錯誤?你在畫面上畫畫嗎?如果是這樣,考慮重寫paintComponent方法而不是paint方法,並確保始終調用super.paintComponent(g); – 2012-07-18 23:36:40
錯誤消息是太大了,一個評論 第一部分 異常在線程「AWT-EventQueue的 - 0」 java.lang.ArrayIndexOutOfBoundsException:沒有這樣的孩子:21 \t在java.awt.Container.getComponent(來源不明) \t在javax.swing.JComponent.rectangleIsObscured(來源不明) \t在javax.swing.JComponent.paint(來源不明) \t在javax.swing.JComponent.paintToOffscreen(來源不明) \t在javax.swing.RepaintManager中的$ PaintManager .paintDoubleBuffered(來源不明) \t在javax.swing.RepaintManager中的$ PaintManager.paint(來源不明) ) – 2012-07-18 23:41:13