Topic: JOptionPane的奇怪出错

  Print this page

1.JOptionPane的奇怪出错 Copy to clipboard
Posted by: cxp108
Posted on: 2003-10-14 10:58

在Applet中编写以下代码
public class ClusterParaDialog extends JDialog{
.
.
.
.
private class cycleSaNoTFInputVerifier extends InputVerifier{
.
.
.
JOptionPane.showMessageDialog(ClusterParaDialog.this,"content","dialog",JOptionPane.INFORMATION_MESSAGE);
.
.
.
.


.
.
}
编译通过了
运行环境:JRE 1.3.1 就不会出现问题,显示正常
但是运行环境1.4.0~2版本的JRE会出现以下问题:

----------------------------------------------------------------------------------------
Exception occurred during event dispatching:

java.lang.StackOverflowError

  at sun.java2d.Disposer.add(Disposer.java:91)

  at sun.java2d.Disposer.addRecord(Disposer.java:68)

  at sun.awt.windows.Win32SurfaceData.initOps(Native Method)

  at sun.awt.windows.Win32SurfaceData.<init>(Win32SurfaceData.java:432)

  at sun.awt.windows.Win32SurfaceData.createData(Win32SurfaceData.java:311)

  at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:321)

  at sun.awt.windows.WComponentPeer.setBounds(WComponentPeer.java:133)

  at sun.awt.windows.WComponentPeer.initialize(WComponentPeer.java:523)

  at sun.awt.windows.WCanvasPeer.initialize(WCanvasPeer.java:63)

  at sun.awt.windows.WPanelPeer.initialize(WPanelPeer.java:57)

  at sun.awt.windows.WWindowPeer.initialize(WWindowPeer.java:81)

  at sun.awt.windows.WDialogPeer.initialize(WDialogPeer.java:48)

  at sun.awt.windows.WComponentPeer.<init>(WComponentPeer.java:497)

  at sun.awt.windows.WCanvasPeer.<init>(WCanvasPeer.java:29)

  at sun.awt.windows.WPanelPeer.<init>(WPanelPeer.java:53)

  at sun.awt.windows.WWindowPeer.<init>(WWindowPeer.java:77)

  at sun.awt.windows.WDialogPeer.<init>(WDialogPeer.java:26)

  at sun.awt.windows.WToolkit.createDialog(WToolkit.java:368)

  at java.awt.Dialog.addNotify(Dialog.java:387)

  at java.awt.Window.pack(Window.java:428)

  at javax.swing.JOptionPane.createDialog(JOptionPane.java:899)

  at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:819)

  at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:624)

  at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:595)

  at com.cet.ui.ctcui.ClusterParaDialog$cycleSaNoTFInputVerifier.verify(ClusterParaDialog.java:1833)

  at javax.swing.InputVerifier.shouldYieldFocus(InputVerifier.java:114)

  at javax.swing.JComponent.runInputVerifier(JComponent.java:1104)

  at javax.swing.JComponent.requestFocus(JComponent.java:1109)

  at javax.swing.plaf.basic.BasicOptionPaneUI.selectInitialValue(BasicOptionPaneUI.java:849)

  at javax.swing.JOptionPane.selectInitialValue(JOptionPane.java:2126)

  at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:821)

  at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:624)

  at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:595)

  at com.cet.ui.ctcui.ClusterParaDialog$cycleSaNoTFInputVerifier.verify(ClusterParaDialog.java:1833)

  at javax.swing.InputVerifier.shouldYieldFocus(InputVerifier.java:114)

  at javax.swing.JComponent.runInputVerifier(JComponent.java:1104)

  at javax.swing.JComponent.requestFocus(JComponent.java:1109)

  at javax.swing.plaf.basic.BasicOptionPaneUI.selectInitialValue(BasicOptionPaneUI.java:849)

  at javax.swing.JOptionPane.selectInitialValue(JOptionPane.java:2126)

  at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:821)

  at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:624)

  at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:595)

  at com.cet.ui.ctcui.ClusterParaDialog$cycleSaNoTFInputVerifier.verify(ClusterParaDialog.java:1833)

  at javax.swing.InputVerifier.shouldYieldFocus(InputVerifier.java:114)

  at javax.swing.JComponent.runInputVerifier(JComponent.java:1104)

  at javax.swing.JComponent.requestFocus(JComponent.java:1109)

  at javax.swing.plaf.basic.BasicOptionPaneUI.selectInitialValue(BasicOptionPaneUI.java:849)

  at javax.swing.JOptionPane.selectInitialValue(JOptionPane.java:2126)

  at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:821)

  at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:624)

  at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:595)

  at com.cet.ui.ctcui.ClusterParaDialog$cycleSaNoTFInputVerifier.verify(ClusterParaDialog.java:1833)
........
------------------------------

这个问题困扰了小弟很久,希望众大虾们帮着做个试验,看看到底是不
是JRE的问题,还是小弟代码写得不当所至。

2.Re:JOptionPane的奇怪出错 [Re: cxp108] Copy to clipboard
Posted by: jameszhang
Posted on: 2003-10-15 19:30

是你的内部类调的,JOptionPane 已经不属于了ClusterParaDialog ,是不是因为这个呢?

3.Re:JOptionPane的奇怪出错 [Re: cxp108] Copy to clipboard
Posted by: floater
Posted on: 2003-10-15 22:06

I suspect that it's an infinite loop, like a cat chasing his own tail. Saw something similar before. You call swing classes and swing classes call your classes.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923