Java Code Examples for java.awt.Dialog#setResizable()

The following examples show how to use java.awt.Dialog#setResizable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Update.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public boolean showDialog() {
    DialogDescriptor dialogDescriptor = new DialogDescriptor(panel,
          org.openide.util.NbBundle.getMessage(RevertModifications.class, "CTL_UpdateDialog", repository.getName()), // NOI18N
          true,
          new Object[] {okButton, cancelButton},
          okButton,
          DialogDescriptor.DEFAULT_ALIGN,
          new HelpCtx(this.getClass()),
          null);
    
    dialogDescriptor.setValid(false);
    
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);     
    dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RevertModifications.class, "ACSD_UpdateDialog", repository.getName())); // NOI18N
    dialog.setVisible(true);
    dialog.setResizable(false);
    boolean ret = dialogDescriptor.getValue() == okButton;
    return ret;       
}
 
Example 2
Source File: UiUtils.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
public static void makeOwningDialogResizable(@Nonnull final Component component, @Nonnull @MustNotContainNull final Runnable... extraActions) {
  final HierarchyListener listener = new HierarchyListener() {
    @Override
    public void hierarchyChanged(@Nonnull final HierarchyEvent e) {
      final Window window = SwingUtilities.getWindowAncestor(component);
      if (window instanceof Dialog) {
        final Dialog dialog = (Dialog) window;
        if (!dialog.isResizable()) {
          dialog.setResizable(true);
          component.removeHierarchyListener(this);

          for (final Runnable r : extraActions) {
            r.run();
          }
        }
      }
    }
  };
  component.addHierarchyListener(listener);
}
 
Example 3
Source File: AboutAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void performAction () {
    DialogDescriptor descriptor = new DialogDescriptor(
        new org.netbeans.core.ui.ProductInformationPanel (),
        NbBundle.getMessage(AboutAction.class, "About_title"),
        true,
            new Object[0],
            null,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null);
    Dialog dlg = null;
    try {
        dlg = DialogDisplayer.getDefault().createDialog(descriptor);
        if( Utilities.isMac() && dlg instanceof JDialog ) {
            JDialog d = (JDialog) dlg;
            InputMap map = d.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
            map.put(KeyStroke.getKeyStroke(KeyEvent.VK_W, KeyEvent.META_MASK), "Escape"); //NOI18N
            //#221571
            d.getRootPane().putClientProperty("nb.about.dialog", Boolean.TRUE); //NOI18N
        }
        dlg.setResizable(false);
        dlg.setVisible(true);
    } finally {
        if (dlg != null) {
            dlg.dispose();
        }
    }
}
 
Example 4
Source File: UpdateTo.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean showDialog() {
    DialogDescriptor dialogDescriptor = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(UpdateTo.class, "CTL_UpdateToDialog")); // NOI18N
    dialogDescriptor.setOptions(new Object[] {okButton, cancelButton});

    dialogDescriptor.setModal(true);
    dialogDescriptor.setHelpCtx(new HelpCtx(this.getClass()));
    dialogDescriptor.setValid(false);

    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
    dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(UpdateTo.class, "ACSD_UpdateToDialog")); // NOI18N
    dialog.setVisible(true);
    dialog.setResizable(false);
    boolean ret = dialogDescriptor.getValue() == okButton;
    return ret;
}
 
Example 5
Source File: RevertModifications.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean showDialog() {
    DialogDescriptor dialogDescriptor = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(RevertModifications.class, "CTL_RevertDialog")); // NOI18N
    dialogDescriptor.setOptions(new Object[] {okButton, cancelButton});
    
    dialogDescriptor.setModal(true);
    dialogDescriptor.setHelpCtx(new HelpCtx(this.getClass()));
    dialogDescriptor.setValid(false);
    
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);     
    dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RevertModifications.class, "ACSD_RevertDialog")); // NOI18N
    dialog.setVisible(true);
    dialog.setResizable(false);
    boolean ret = dialogDescriptor.getValue() == okButton;
    return ret;       
}
 
Example 6
Source File: CertPassphraseDlg.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean askPassword(ExecutionEnvironment execEnv, String key) {
    Mnemonics.setLocalizedText(promptLabel, NbBundle.getMessage(CertPassphraseDlg.class, "CertPassphraseDlg.promptLabel.text", key)); // NOI18N

    tfUser.setText(execEnv.getUser());

    String hostName = execEnv.getHost();
    if (execEnv.getSSHPort() != 22) {
        hostName += ":" + execEnv.getSSHPort(); //NOI18N
    }
    tfHost.setText(hostName); // NOI18N

    DialogDescriptor dd = new DialogDescriptor(this,
            NbBundle.getMessage(CertPassphraseDlg.class, "CertPassphraseDlg.title.text"), // NOI18N
            true, // NOI18N
            new Object[]{
                DialogDescriptor.OK_OPTION,
                DialogDescriptor.CANCEL_OPTION},
            DialogDescriptor.OK_OPTION,
            DialogDescriptor.DEFAULT_ALIGN, null, null);

    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setResizable(false);

    try {
        dialog.setVisible(true);
    } catch (Throwable th) {
        if (!(th.getCause() instanceof InterruptedException)) {
            throw new RuntimeException(th);
        }
        dd.setValue(DialogDescriptor.CANCEL_OPTION);
    } finally {
        dialog.dispose();
    }

    return dd.getValue() == DialogDescriptor.OK_OPTION;
}
 
Example 7
Source File: PasswordDlg.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean askPassword(ExecutionEnvironment execEnv, String prompt) {
    tfUser.setText(execEnv.getUser());
    String hostName = execEnv.getHost();
    if (execEnv.getSSHPort() != 22) {
        hostName += ":" + execEnv.getSSHPort(); //NOI18N
    }
    tfHost.setText(hostName); // NOI18N
    cbRememberPwd.setSelected(PasswordManager.getInstance().isRememberPassword(execEnv));

    DialogDescriptor dd = new DialogDescriptor(this,
            loc("TITLE_Password"), true, // NOI18N
            new Object[]{
                DialogDescriptor.OK_OPTION,
                DialogDescriptor.CANCEL_OPTION},
            DialogDescriptor.OK_OPTION,
            DialogDescriptor.DEFAULT_ALIGN, null, null);

    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setResizable(false);

    try {
        dialog.setVisible(true);
    } catch (Throwable th) {
        if (!(th.getCause() instanceof InterruptedException)) {
            throw new RuntimeException(th);
        }
        dd.setValue(DialogDescriptor.CANCEL_OPTION);
    } finally {
        dialog.dispose();
    }

    return dd.getValue() == DialogDescriptor.OK_OPTION;
}
 
Example 8
Source File: AuthTypeSelectorDlg.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param auth
 * @return false if cancelled
 */
public boolean initAuthentication(final Authentication auth) {
    AuthenticationSettingsPanel vpanel = new AuthenticationSettingsPanel(auth, false);
    vpanel.addValidationListener(new AuthValidationListener());
    cfgPanel.add(vpanel, BorderLayout.CENTER);

    DialogDescriptor dd = new DialogDescriptor(this,
            NbBundle.getMessage(AuthTypeSelectorDlg.class, "TITLE_AuthTypeSelectorDlg"), // NOI18N
            true, new Object[]{ok, DialogDescriptor.CANCEL_OPTION}, ok,
            DialogDescriptor.DEFAULT_ALIGN, null, null);

    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setResizable(false);

    try {
        dialog.setVisible(true);
    } catch (Throwable th) {
        if (!(th.getCause() instanceof InterruptedException)) {
            throw new RuntimeException(th);
        }
        dd.setValue(DialogDescriptor.CANCEL_OPTION);
    } finally {
        dialog.dispose();
    }

    if (dd.getValue() == ok) {
        vpanel.applyChanges(null);
        return true;
    } else {
        return false;
    }
}
 
Example 9
Source File: Clone.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean showDialog() {
    DialogDescriptor dialogDescriptor = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(Clone.class, "CTL_CloneDialog"),  // NOI18N
            true, new Object[] {okButton, cancelButton}, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(this.getClass()), null);
    dialogDescriptor.setValid(false);
    
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);     
    dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Clone.class, "ACSD_CloneDialog")); // NOI18N
    dialog.setVisible(true);
    dialog.setResizable(false);
    boolean ret = dialogDescriptor.getValue() == okButton;
    return ret;       
}
 
Example 10
Source File: StringTableCellEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void hierarchyChanged(HierarchyEvent e) {
    Window window = SwingUtilities.getWindowAncestor(pane);
    if (window instanceof Dialog) {
        Dialog dialog = (Dialog) window;
        if (!dialog.isResizable()) {
            dialog.setResizable(true);
        }
    }
}
 
Example 11
Source File: ChangeWindowResizabiltyTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Robot robot = new Robot();
    for(int i = 0; i < 10; i++) {
        Dialog dialog = new Dialog((Frame) null);
        dialog.setLocation(100, 100);
        Component panel = new Panel();
        panel.setPreferredSize(new Dimension(200, 100));
        dialog.add(panel);
        dialog.pack();
        dialog.setVisible(true);
        robot.waitForIdle();
        robot.delay(200);

        Point frameLoc = dialog.getLocationOnScreen();
        Point contentLoc = panel.getLocationOnScreen();

        System.out.println("Decor location " + frameLoc);
        System.out.println("Content location " + contentLoc);

        dialog.setResizable(false);
        robot.waitForIdle();
        robot.delay(200);

        Point l = dialog.getLocationOnScreen();
        if (!l.equals(frameLoc)) {
            dialog.dispose();
            throw new RuntimeException("Decorated frame location moved " +
                    "after setResizable(false)" + l);
        }

        l = panel.getLocationOnScreen();
        if (!l.equals(contentLoc)) {
            dialog.dispose();
            throw new RuntimeException("Content location moved after " +
                    "setResizable(false)" + l);
        }

        if (panel.getLocationOnScreen().y <
                  dialog.getLocationOnScreen().y + dialog.getInsets().top) {
            dialog.dispose();
            throw new RuntimeException(
                        "Wrong content position after setResizable(false)");
        }

        dialog.setResizable(true);
        robot.waitForIdle();
        robot.delay(200);

        l = dialog.getLocationOnScreen();
        if (!l.equals(frameLoc)) {
            dialog.dispose();
            throw new RuntimeException("Decorated frame location moved " +
                    "after setResizable(true)" + l);
        }

        l = panel.getLocationOnScreen();
        if (!l.equals(contentLoc)) {
            dialog.dispose();
            throw new RuntimeException("Content location moved after " +
                    "setResizable(true)" + l);
        }
        if (panel.getLocationOnScreen().y <
                  dialog.getLocationOnScreen().y + dialog.getInsets().top) {
            dialog.dispose();
            throw new RuntimeException(
                         "Wrong content position after setResizable(true)");
        }

        dialog.dispose();
    }
}
 
Example 12
Source File: CategoryArchiveFiles.java    From nb-ci-plugin with GNU General Public License v2.0 4 votes vote down vote up
private void addZipButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addZipButtonActionPerformed
    final CIEntry entry = new CIEntry();
    final CIEntryEditPanel panel = new CIEntryEditPanel();
    panel.load(entry);
    panel.setFileEntryMap(model.getEntryMap());

    final DialogDescriptor descriptor = new DialogDescriptor(
            panel,
            getMessage("CTL_AddArchiveFile"), // NOI18N
            true,
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.OK_OPTION,
            null);
    descriptor.setClosingOptions(new Object[]{});
    NotificationLineSupport notificationLineSupport = descriptor.createNotificationLineSupport();
    panel.setValidityObjects(descriptor, notificationLineSupport);

    final Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
    dialog.getAccessibleContext().setAccessibleName(getMessage("ACSN_Dialog")); // NOI18N
    dialog.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_Dialog")); // NOI18N
    dialog.setResizable(false);
    descriptor.setButtonListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (DialogDescriptor.OK_OPTION.equals(e.getSource())) {
            }
            dialog.setVisible(false);
        }
    });

    dialog.setVisible(true);

    if (NotifyDescriptor.OK_OPTION.equals(descriptor.getValue())) {
        panel.store(entry);
        model.addEntry(entry);
        int rowIndex = entryTable.getRowCount() - 1;
        entryTable.setRowSelectionInterval(rowIndex, rowIndex);
    }

    dialog.dispose();
}
 
Example 13
Source File: CategoryArchiveFiles.java    From nb-ci-plugin with GNU General Public License v2.0 4 votes vote down vote up
private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
    int rowIndex = entryTable.getSelectedRow();

    if (rowIndex >= 0) {
        final CIEntry entry = model.getEntry(rowIndex);
        final CIEntryEditPanel panel = new CIEntryEditPanel();
        panel.load(entry);
        panel.setFileEntryMap(model.getEntryMap(entry));

        final DialogDescriptor descriptor = new DialogDescriptor(
                panel,
                getMessage("CTL_AddArchiveFile"), // NOI18N
                true,
                NotifyDescriptor.OK_CANCEL_OPTION,
                NotifyDescriptor.OK_OPTION,
                null);
        descriptor.setClosingOptions(new Object[]{});
        NotificationLineSupport notificationLineSupport = descriptor.createNotificationLineSupport();
        panel.setValidityObjects(descriptor, notificationLineSupport);

        final Dialog dialog = DialogDisplayer.getDefault().createDialog(descriptor);
        dialog.getAccessibleContext().setAccessibleName(getMessage("ACSN_Dialog")); // NOI18N
        dialog.getAccessibleContext().setAccessibleDescription(getMessage("ACSD_Dialog")); // NOI18N
        dialog.setResizable(false);
        descriptor.setButtonListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (DialogDescriptor.OK_OPTION.equals(e.getSource())) {
                }
                dialog.setVisible(false);
            }
        });

        dialog.setVisible(true);

        if (NotifyDescriptor.OK_OPTION.equals(descriptor.getValue())) {
            panel.store(entry);
            model.setEntry(rowIndex, entry);
            entryTable.setRowSelectionInterval(rowIndex, rowIndex);
        }

        dialog.dispose();
    }
}
 
Example 14
Source File: Dialogs.java    From visualvm with GNU General Public License v2.0 3 votes vote down vote up
private static Dialog dialogImpl(String caption, Object message, int type, Object... options) {
    DialogDescriptor dd = new DialogDescriptor(message, caption);
    dd.setMessageType(type);
    
    dd.setOptions(options);
    
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    
    d.setIconImages(getIcons());
    d.setResizable(false);
    
    return d;
}