Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Dialog Introduction

A dialog can be either modal or modeless. A modal dialog blocks user input to all other windows in the same application when it is visible. You have to close a modal dialog before other windows in the same application can get focus. A modeless one does not block user input. A dialog can belong to another dialog or a frame. Or, it can stand alone like a JFrame. class Help extends JDialog {   Help(Frame frame, String title) {     super(frame, title);     setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);     try {       JEditorPane ep = new JEditorPane("file:///" + new File("").getAbsolutePath() + "/uchelp.html");       ep.setEnabled(false);       getContentPane().add(ep);     } catch (IOException ioe) {       JOptionPane.showMessageDialog(frame, "Unable to install editor pane");       return;     }     setSize(200, 200);     setLocationRelativeTo(frame);     setVisible(true);   } }