hide();
setVisible(false);
    public SelectionDialog() {      super();      setTitle("Display Modes");      modes = getAvailableDisplayModes();      String[] strings = modesToString(modes);      final JList modeList = new JList(strings);      modeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);      modeList.setSelectedIndex(0);      JScrollPane scroller = new JScrollPane(modeList);      getContentPane().setLayout(new BorderLayout());      JPanel panel = new JPanel();      panel.setLayout(new BorderLayout());      panel.add(new JLabel("Select full-screen display mode,"), BorderLayout.NORTH);      panel.add(new JLabel("or Cancel for windowed mode:"),     BorderLayout.CENTER);      getContentPane().add(BorderLayout.NORTH, panel);      getContentPane().add(BorderLayout.CENTER, scroller);      JPanel buttonPanel = new JPanel();      buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));      buttonPanel.add(Box.createGlue());      JButton button = new JButton("OK");      button.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent e) {            selectedIndex = modeList.getSelectedIndex();            done = true;            synchronized(monitor) {              monitor.notify();            }            hide();            dispose();          }        });      buttonPanel.add(button);      buttonPanel.add(Box.createHorizontalStrut(10));      button = new JButton("Cancel");      button.addActionListener(new ActionListener() {          public void actionPerformed(ActionEvent e) {            selectedIndex = -1;            done = true;            synchronized(monitor) {              monitor.notify();            }            hide();            dispose();          }        });      buttonPanel.add(button);      buttonPanel.add(Box.createGlue());      getContentPane().add(BorderLayout.SOUTH, buttonPanel);      setSize(300, 200);      center(this, Toolkit.getDefaultToolkit().getScreenSize());    }