请问如何使用JInternalFrame实现关闭窗口内部生成的窗口而不影响自身?
在运行“StudentInformationScan.java”时生成一个窗口,在窗口中我点“修改”按钮时就ReviseStudentInformationrevise=...
在运行“StudentInformationScan.java”时生成一个窗口,在窗口中我点“修改”按钮时就 ReviseStudentInformation revise=new
ReviseStudentInformation(student);
生成一个新窗口,当我关闭新生成的ReviseStudentInformation窗口时,最开始生成的窗口(StudentInformationScan.java)也被关闭了!但
是我不想关闭最开始的那个窗口?请问该如何解决决?听说将ReviseStudentInformation转化为StudentInformationScan的内嵌窗口,就可以
解决。好像要用到JInternalFrame
package JPanel;
import java.util.Vector;
import java.awt.*;
import javax.swing.*;
import DAO.*;
public class StudentInformationScan extends JFrame implements ActionListener{
private JLabel title;
private JButton revise,delete,addRow;
.......
public StudentInformationScan()
{
p=new JPanel();
revise=new JButton("修改");
revise.setBounds(120, 350, 60, 25);
revise.addActionListener(this);
p.add(revise);
this.setTitle("学生信息浏览");
this.getContentPane().add(p);
this.setSize(510, 500);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public JScrollPane getJScrollPane()
{
..........
return scrollpane;
}
public JTable getJTable()
{
........
return table;
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==revise)
{
System.out.println("aaaaaaaaa");
if(table.getSelectedRow()==-1)
{
JOptionPane.showMessageDialog(null, "请选择要修改的行!");
}
else
{
.........
ReviseStudentInformation revise=new ReviseStudentInformation(student);
}
}
}
}
public static void main(String[] args) {
StudentInformationScan student=new StudentInformationScan();
}
}
package JPanel;
import DAO.*;
import javax.swing.*;
import DAO.DBSQLManager;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ReviseStudentInformation extends JFrame implements ActionListener{
public ReviseStudentInformation(StudentVO student)
{
.........
revise=new JButton("修改");
revise.setBounds(140, 270, 60, 25);
revise.addActionListener(this);
this.add(revise);
this.setSize(400, 350);
this.setLocation(100, 100);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==revise)
{
........
}
}
} 展开
ReviseStudentInformation(student);
生成一个新窗口,当我关闭新生成的ReviseStudentInformation窗口时,最开始生成的窗口(StudentInformationScan.java)也被关闭了!但
是我不想关闭最开始的那个窗口?请问该如何解决决?听说将ReviseStudentInformation转化为StudentInformationScan的内嵌窗口,就可以
解决。好像要用到JInternalFrame
package JPanel;
import java.util.Vector;
import java.awt.*;
import javax.swing.*;
import DAO.*;
public class StudentInformationScan extends JFrame implements ActionListener{
private JLabel title;
private JButton revise,delete,addRow;
.......
public StudentInformationScan()
{
p=new JPanel();
revise=new JButton("修改");
revise.setBounds(120, 350, 60, 25);
revise.addActionListener(this);
p.add(revise);
this.setTitle("学生信息浏览");
this.getContentPane().add(p);
this.setSize(510, 500);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public JScrollPane getJScrollPane()
{
..........
return scrollpane;
}
public JTable getJTable()
{
........
return table;
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==revise)
{
System.out.println("aaaaaaaaa");
if(table.getSelectedRow()==-1)
{
JOptionPane.showMessageDialog(null, "请选择要修改的行!");
}
else
{
.........
ReviseStudentInformation revise=new ReviseStudentInformation(student);
}
}
}
}
public static void main(String[] args) {
StudentInformationScan student=new StudentInformationScan();
}
}
package JPanel;
import DAO.*;
import javax.swing.*;
import DAO.DBSQLManager;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ReviseStudentInformation extends JFrame implements ActionListener{
public ReviseStudentInformation(StudentVO student)
{
.........
revise=new JButton("修改");
revise.setBounds(140, 270, 60, 25);
revise.addActionListener(this);
this.add(revise);
this.setSize(400, 350);
this.setLocation(100, 100);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==revise)
{
........
}
}
} 展开
1个回答
2009-09-30
展开全部
那就用呗,哪有在JFrame里面放JFrame的啊。。
把JInternalFrame放在JDesktopPane里面就可以了,JDesktopPane再放在JFrame里面
把JInternalFrame放在JDesktopPane里面就可以了,JDesktopPane再放在JFrame里面
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询