当前位置: 技术问答>java相关
拜托您看一下,谢谢
来源: 互联网 发布时间:2015-02-25
本文导语: 运行这个程序,关闭子窗口时,弹出 :1326) at javax.swing.JInternalFrame.dispose(JInternalFrame.java:1488) at JInternalFrameTest.internalFrameClosed(JInternalFrameTest.java:46) at javax.swing.JInternalFrame.fireInternalFrameEvent(JInternalFrame.java 是什么错误 im...
运行这个程序,关闭子窗口时,弹出
:1326)
at javax.swing.JInternalFrame.dispose(JInternalFrame.java:1488)
at JInternalFrameTest.internalFrameClosed(JInternalFrameTest.java:46)
at javax.swing.JInternalFrame.fireInternalFrameEvent(JInternalFrame.java
是什么错误
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class JInternalFrameTest extends JFrame implements
ActionListener,InternalFrameListener{
private int count=0;
private JMenuItem jmi1;
private JDesktopPane jdp;
public static void main(String args[]){
JInternalFrameTest test=new JInternalFrameTest();
test.setSize(600,400);
test.setVisible(true);
}
public JInternalFrameTest(){
JMenuBar jmb=new JMenuBar();
JMenu jm=new JMenu("window");
jmi1=new JMenuItem("new");
jmi1.addActionListener(this);
jm.add(jmi1);
jmb.add(jm);
setJMenuBar(jmb);
jdp=new JDesktopPane();
getContentPane().add(jdp);
}
public void actionPerformed(ActionEvent e){
int i;
JMenuItem jmi=(JMenuItem)e.getSource();
if (jmi==jmi1){
JInternalFrame jif=new JInternalFrame(Integer.toString(count++),true,true,
true,true);
jif.setSize(300,200);
jdp.add(jif);
jif.show();
jif.addInternalFrameListener(this);
}
}
public void internalFrameActivated(InternalFrameEvent e){
}
public void internalFrameClosed(InternalFrameEvent e){
((JInternalFrame)e.getSource()).dispose();
}
public void internalFrameClosing(InternalFrameEvent e){
}
public void internalFrameDeactivated(InternalFrameEvent e){
}
public void internalFrameDeiconified(InternalFrameEvent e){
}
public void internalFrameOpened(InternalFrameEvent e){
}
public void internalFrameIconified(InternalFrameEvent e){
}
}
:1326)
at javax.swing.JInternalFrame.dispose(JInternalFrame.java:1488)
at JInternalFrameTest.internalFrameClosed(JInternalFrameTest.java:46)
at javax.swing.JInternalFrame.fireInternalFrameEvent(JInternalFrame.java
是什么错误
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class JInternalFrameTest extends JFrame implements
ActionListener,InternalFrameListener{
private int count=0;
private JMenuItem jmi1;
private JDesktopPane jdp;
public static void main(String args[]){
JInternalFrameTest test=new JInternalFrameTest();
test.setSize(600,400);
test.setVisible(true);
}
public JInternalFrameTest(){
JMenuBar jmb=new JMenuBar();
JMenu jm=new JMenu("window");
jmi1=new JMenuItem("new");
jmi1.addActionListener(this);
jm.add(jmi1);
jmb.add(jm);
setJMenuBar(jmb);
jdp=new JDesktopPane();
getContentPane().add(jdp);
}
public void actionPerformed(ActionEvent e){
int i;
JMenuItem jmi=(JMenuItem)e.getSource();
if (jmi==jmi1){
JInternalFrame jif=new JInternalFrame(Integer.toString(count++),true,true,
true,true);
jif.setSize(300,200);
jdp.add(jif);
jif.show();
jif.addInternalFrameListener(this);
}
}
public void internalFrameActivated(InternalFrameEvent e){
}
public void internalFrameClosed(InternalFrameEvent e){
((JInternalFrame)e.getSource()).dispose();
}
public void internalFrameClosing(InternalFrameEvent e){
}
public void internalFrameDeactivated(InternalFrameEvent e){
}
public void internalFrameDeiconified(InternalFrameEvent e){
}
public void internalFrameOpened(InternalFrameEvent e){
}
public void internalFrameIconified(InternalFrameEvent e){
}
}
|
46 :((JInternalFrame)e.getSource()).dispose();
这条语句重复触发了Frame关闭事件造成递归调用,从而引起堆栈译出,去掉这条语句。
这条语句重复触发了Frame关闭事件造成递归调用,从而引起堆栈译出,去掉这条语句。