This is the problematic code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class myDialog extends JDialog {
/** Creates a new instance of myDialog */
public myDialog(){
setModal(true);
setTitle("Some data into a dialog window");
getContentPane().setLayout(null);
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
JButton btnOpenJFrame = new JButton("Open a JFrame()");
btnOpenJFrame.setSize(300, 25);
getContentPane().add(btnOpenJFrame);
btnOpenJFrame.setLocation(30, 30);
pack();
setLocation(10, 10);
setSize(400, 300);
setResizable(false);
addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
myDialog.this.dispose();
System.exit(0);
}
}
);
btnOpenJFrame.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
JFrame myJFrame = new JFrame(
"Here I perform some edit operations");
myJFrame.setDefaultCloseOperation(
JFrame.DISPOSE_ON_CLOSE);
myJFrame.setSize(600, 500);
myJFrame.setLocation(10, 10);
myJFrame.show();
myJFrame.requestFocus();
}
}
);
}
/** Main entry point */
public static void main(
String args[]){
new myDialog().show();
}
}