Java窗体

来源:百度知道 编辑:UC知道 时间:2024/05/17 21:53:01
比如说 有2个窗体 A和B .

在A窗体上面打开 B窗体 .

然后 如果不关闭B窗体 就不能选择A窗体 ..

这个要怎么编写 ..
就像 帮助 - 关于 那样的窗口 ..

import javax.swing.*;

public class FrameTest {
public static void main(String[] args) {
new F();
}
}

class F extends JFrame{
JButton b;
F(){
this.setSize(400,300);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b = new JButton("帮助");
add(b);
b.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(java.awt.event.ActionEvent e){
showDialog();
}
});
this.setVisible(true);
}
//显示一个对话框,此时主窗口不能操作
private void showDialog(){
JDialog d = new JDialog(this,true);
d.setTitle("haha,haha...");
d.setSize(300,100);
d.setVisible(true);
}
}

import javax.swing.JDialog;
import javax.swing.JFrame;

public class My extends JFrame{
public My(){
this.setSize(500,500);
this.setVisible(true);
JDialog you = new JDialog();<