import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
class a{
public static void main(String[] args) {
JFrame JF=new JFrame();
JF.setSize(500,500);
JF.setLocationRelativeTo(null);
JF.setDefaultCloseOperation(3);
JF.setResizable(false);
JF.setLayout(null);
JButton JB=new JButton("必须关闭新弹窗口才能操作原窗口");
JB.setBounds(0,0,250,100);
JButton JB1=new JButton("无需关闭新窗口可继续操作原窗口");
JB1.setBounds(250,0,250,100);
JDialog JD=new JDialog();
JD.setBounds(0,0,500,500);
JDialog JD1=new JDialog();
JD1.setBounds(800,300,500,500);
JB.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JD.setModal(true);
if(e.getSource()==JB) {
JD.setVisible(true);
}
}
});
JB1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JD1.setModal(false);
if(e.getSource()==JB1) {
JD1.setVisible(true);
}
}
});
JF.add(JB);
JF.add(JB1);
JF.setVisible(true);
}
}