Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sory, now I putted the code

 
Mihalache Catalin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the code:

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();
}
}
When I push the button it will appear a frame but I cannot use it!
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your dialog is modal. Change it to modal=false.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic