How do I create a modal Dialog without a Titlebar/close button or if that is not possible, how do I create a modal Window?

Sandip Chitale

The following might work


public class YourFrame extends Frame {

  // blah
  // blah

  private void showModalWindow() {
     Window w = new Window(this);
     w.setLayout(new BorderLayout());
     w.add(new Label("Modal Window"), BorderLayout.CENTER);
     w.pack();
     // or w.setBounds() etc.
     w.addWindowListener(
         new WindowAdapter() {
              public void windowClosed(WindowEvent we) {
                 // remove listener
                 we.getWindow().removeWindowListener(this);
                 // enable outer YourFrame instance
                 setEnabled(true); 
              }
         }
     );
     setEnabled(false);
     w.setVisible(true);
  }
}
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact