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

The following examples show how to use java.awt.Dialog#setVisible() . 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: ModalDialogOrderingTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {

        final Frame frame = new Frame("Test");
        frame.setSize(400, 400);
        frame.setBackground(FRAME_COLOR);
        frame.setVisible(true);

        final Dialog modalDialog = new Dialog(null, true);
        modalDialog.setTitle("Modal Dialog");
        modalDialog.setSize(400, 200);
        modalDialog.setBackground(DIALOG_COLOR);
        modalDialog.setModal(true);

        new Thread(new Runnable() {

            @Override
            public void run() {
                runTest(modalDialog, frame);
            }
        }).start();

        modalDialog.setVisible(true);
    }
 
Example 2
Source File: WatchesActionsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static void customize (WatchesTreeModel.EmptyWatch w) {

        WatchPanel wp = new WatchPanel("");
        JComponent panel = wp.getPanel();

        org.openide.DialogDescriptor dd = new org.openide.DialogDescriptor(
            panel,
            NbBundle.getMessage(WatchesActionsProvider.class, "CTL_WatchDialog_Title", "")
        );
        dd.setHelpCtx(new HelpCtx("debug.add.watch"));
        Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
        dialog.setVisible(true);
        dialog.dispose();

        if (dd.getValue() != org.openide.DialogDescriptor.OK_OPTION) return;
        w.setExpression(wp.getExpression());
    }
 
Example 3
Source File: LibrariesCustomizer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages("LibrariesCustomizer.customizeLibrary.title=Customize Library")
private static boolean customizeLibrary(org.netbeans.modules.project.libraries.ui.LibrariesCustomizer customizer,
        LibraryImplementation activeLibrary) {
    customizer.hideLibrariesList();
    customizer.setBorder(new EmptyBorder(12, 8, 0, 10));
    customizer.setSelectedLibrary (activeLibrary);
    DialogDescriptor descriptor = new DialogDescriptor(customizer, LibrariesCustomizer_customizeLibrary_title());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(descriptor);
    setAccessibleDescription(dlg, customizer.getAccessibleContext().getAccessibleDescription());
    try {
        dlg.setVisible(true);
        if (descriptor.getValue() == DialogDescriptor.OK_OPTION) {
            customizer.apply();
            return true;
        } else {
            return false;
        }
    } finally {
        dlg.dispose();
    }
}
 
Example 4
Source File: ShelveChangesSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean openDialog (JPanel additionalOptions, String helpCtx) {
    ShelveChangesPanel panel = new ShelveChangesPanel(additionalOptions);
    initializePatchName(panel.txtPatchName);
    panel.lblError.setVisible(false);
    JButton okButton = new JButton();
    Mnemonics.setLocalizedText(okButton, NbBundle.getMessage(ShelveChangesSupport.class, "CTL_ShelveChangesPanel.okButton.text")); //NOI18N
    DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(ShelveChangesSupport.class, "LBL_ShelveChangesPanel.title"), //NOI18N
            true, new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(helpCtx), null);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    panel.txtPatchName.getDocument().addDocumentListener(new PatchNameListener(panel, okButton, dialog));
    dialog.setVisible(true);
    if (dd.getValue() == okButton) {
        patchName = panel.txtPatchName.getText().trim();
        return !patchName.isEmpty();
    } else {
        return false;
    }
}
 
Example 5
Source File: FocusTransitionTest.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void run() {
    Dialog dialog = new Dialog(frame);
    dialog.setSize(300, 100);
    dialog.setVisible(true);

    try {
        sleep(delay);
    } catch (InterruptedException ie) {
        ie.printStackTrace();
    }

    dialog.setVisible(false);
    dialog.dispose();

    synchronized (frame) {
        frame.notify();
    }
}
 
Example 6
Source File: CustomizerCompile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void addOptionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addOptionButtonActionPerformed
    final AddProcessorOption panel = new AddProcessorOption();
    final DialogDescriptor desc = new DialogDescriptor(panel, NbBundle.getMessage (CustomizerCompile.class, "LBL_AddProcessorOption_Title")); //NOI18N
    desc.setValid(false);
    panel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            String key = panel.getOptionKey();
            for(String s : key.split("\\.", -1)) { //NOI18N
                if (!SourceVersion.isIdentifier(s)) {
                    desc.setValid(false);
                    return;
                }
            }
            desc.setValid(true);
        }
    });
    Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
    dlg.setVisible (true);
    if (desc.getValue() == DialogDescriptor.OK_OPTION) {
        ((DefaultTableModel)processorOptionsTable.getModel()).addRow(new String[] {panel.getOptionKey(), panel.getOptionValue()});
    }
    dlg.dispose();
}
 
Example 7
Source File: SdksCustomizer.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
/**
 * Shows platforms customizer
 *
 * @param platform which should be seelcted, may be null
 * @return boolean for future extension, currently always true
 */
public static boolean showCustomizer() {
    SdksCustomizer customizer
            = new SdksCustomizer();
    javax.swing.JButton close = new javax.swing.JButton(NbBundle.getMessage(SdksCustomizer.class, "CTL_Close"));
    close.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SdksCustomizer.class, "AD_Close"));
    DialogDescriptor descriptor = new DialogDescriptor(customizer, NbBundle.getMessage(SdksCustomizer.class,
            "TXT_PlatformsManager"), true, new Object[]{close}, close, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx("org.nbandroid.netbeans.gradle.v2.sdk.ui.PlatformsCustomizer"), null); // NOI18N
    Dialog dlg = null;
    try {
        dlg = DialogDisplayer.getDefault().createDialog(descriptor);
        dlg.setVisible(true);
    } finally {
        if (dlg != null) {
            dlg.dispose();
        }
    }
    return true;
}
 
Example 8
Source File: InsertI18nStringAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Basically I18nPanel wrapped by Ok, Cancel and Help buttons shown.
 * Handles OK button.
 */
private void showModalPanel() throws IOException {
    DialogDescriptor dd = new DialogDescriptor(
        createPanel(),
        Util.getString("CTL_InsertI18nDialogTitle"),
        true,
        NotifyDescriptor.OK_CANCEL_OPTION,
        NotifyDescriptor.OK_OPTION,
        DialogDescriptor.DEFAULT_ALIGN,
        new HelpCtx(InsertI18nStringAction.class),
        null
    );
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setVisible(true);
    if (dd.getValue() == NotifyDescriptor.OK_OPTION) {
        insertI18nString();
    }
}
 
Example 9
Source File: ControlPanelAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    JTextComponent component = getTextComponent(e);
    ControlPanel panel = new ControlPanel(component);
    
    DialogDescriptor dd = new DialogDescriptor(
        panel, 
        "Braces Matching Control Panel", //NOI18N
        true,
        null
    ); 
    
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.setVisible(true);
    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
        panel.applyChanges();
    }
}
 
Example 10
Source File: STSIssuedSupportingTokenProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new STSIssuedSupportingToken(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example 11
Source File: AvdManager.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void createDeviceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createDeviceActionPerformed
        // TODO add your handling code here:
        WizardDescriptor wiz = new WizardDescriptor(new CreateAvdWizardIterator(this));
        wiz.putProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, Boolean.TRUE); // NOI18N
        wiz.putProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, Boolean.TRUE); // NOI18N
        wiz.putProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, Boolean.TRUE); // NOI18N
        wiz.putProperty(CreateAvdWizardIterator.DEVICE_MANAGER, deviceManager);
        wiz.putProperty(CreateAvdWizardIterator.IMAGE_MANAGER, systemImageManager);
        wiz.putProperty(CreateAvdWizardIterator.REPO_MANAGER, repoManager);
        wiz.putProperty(CreateAvdWizardIterator.ANDROID_SDK, defaultSdk);
        wiz.putProperty(CreateAvdWizardIterator.AVD_MANAGER, avdManager);
        wiz.setTitle("Create Virtual Device");
        wiz.setTitleFormat(new java.text.MessageFormat("{0}")); // NOI18N
        Dialog dlg = DialogDisplayer.getDefault().createDialog(wiz);
        try {
            dlg.setVisible(true);
            if (wiz.getValue() == WizardDescriptor.FINISH_OPTION) {
//                Set result = wiz.getInstantiatedObjects();
                model.fireTableStructureChanged();
            }
        } finally {
            dlg.dispose();
            //  wiz.getInstantiatedObjects();
        }
    }
 
Example 12
Source File: UnixMultiResolutionSplashTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                String scaleStr = System.getenv("GDK_SCALE");
                if (scaleStr != null && !scaleStr.equals("")) {
                    try {
                        scaleFactors[0] = Float.valueOf(scaleStr);
                    } catch (NumberFormatException ex) {
                        scaleFactors[0] = 1.0f;
                    }
                }
                dialog.setVisible(false);
            }
        };
        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();
        return scaleFactors[0];
    }
 
Example 13
Source File: VariablesPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
    Variable var = explorer.getSelectedNodes()[0].getLookup().lookup(Variable.class);
    VariablePanel p = new VariablePanel(model, var);
    DialogDescriptor dd = new DialogDescriptor (p, NbBundle.getMessage(VariablesPanel.class, "DIALOG_Edit_Variable"), // NOI18N
        true, DialogDescriptor.OK_CANCEL_OPTION, null, null);
    p.setDialogDescriptor(dd);
    Dialog dlg = DialogDisplayer.getDefault().createDialog (dd);
    dlg.setVisible(true);
    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
        var.setValue(p.getVariableLocation());
        setRootNode();
    }
}
 
Example 14
Source File: CustomizerProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    // Close & dispose the the dialog
    Dialog dialog = PROJECT_2_DIALOG.get(project);
    if (dialog != null) {
        dialog.setVisible(false);
        dialog.dispose();
    }
}
 
Example 15
Source File: BindingPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void kerberosCfgButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kerberosCfgButtonActionPerformed
        KerberosConfigPanel panel = new KerberosConfigPanel(binding, project, getUserExpectedConfigVersion());
        DialogDescriptor dlgDesc = new DialogDescriptor(panel,
                NbBundle.getMessage(BindingPanel.class, "LBL_KerberosConfig_Panel_Title")); //NOI18N
        Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

        dlg.setVisible(true);
        if (dlgDesc.getValue() == DialogDescriptor.OK_OPTION) {
            panel.storeState();
        }
}
 
Example 16
Source File: ImportModel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void actionPerformed(ActionEvent ev) {
    final WizardDescriptor wiz = new WizardDescriptor(getPanels());
    // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
    wiz.setTitleFormat(new MessageFormat("{0}"));
    wiz.setTitle("Import Model to Project");
    wiz.putProperty("project", context);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wiz);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wiz.getValue() != WizardDescriptor.FINISH_OPTION;
    ((ModelImporterWizardPanel1) panels[0]).cleanup();
    if (!cancelled) {
        new Thread(new Runnable() {

            public void run() {
                ProgressHandle handle = ProgressHandleFactory.createHandle("Importing Model..");
                handle.start();
                try {
                    copyModel(wiz);
                } catch (Exception e) {
                    Exceptions.printStackTrace(e);
                }
                handle.finish();
            }
        }).start();
    }
}
 
Example 17
Source File: BrowseFolders.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static FileObject showDialog( SourceGroup[] folders, Class target, String preselectedFileName) {
    BrowseFolders bf = new BrowseFolders( folders, target, preselectedFileName);

    JButton selectButton = new JButton( NbBundle.getMessage(BrowseFolders.class,(target == DataFolder.class?"LBL_SelectFolder":"LBL_SelectFile"))); 
    selectButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BrowseFolders.class, (target == DataFolder.class?"ACSD_SelectFolder":"ACSD_SelectFile")));
    JButton cancelButton = new JButton( NbBundle.getMessage(BrowseFolders.class,"LBL_Cancel") ); 
    cancelButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BrowseFolders.class, "ACSD_Cancel"));
    JButton options[] = new JButton[] { 
        //new JButton( NbBundle.getMessage( BrowseFolders.class, "LBL_BrowseFolders_Select_Option") ), // NOI18N
        //new JButton( NbBundle.getMessage( BrowseFolders.class, "LBL_BrowseFolders_Cancel_Option") ), // NOI18N
        selectButton, 
        cancelButton, 
    };
            
    OptionsListener optionsListener = new OptionsListener( bf, target );
    
    options[ 0 ].setActionCommand( OptionsListener.COMMAND_SELECT );
    options[ 0 ].addActionListener( optionsListener );
    options[ 1 ].setActionCommand( OptionsListener.COMMAND_CANCEL );
    options[ 1 ].addActionListener( optionsListener );    
    
    DialogDescriptor dialogDescriptor = new DialogDescriptor( 
        bf,                                     // innerPane
        NbBundle.getMessage(BrowseFolders.class, (target == DataFolder.class? "LBL_BrowseFolders":"LBL_BrowseFiles")), // displayName
        true,                                   // modal
        options,                                // options
        options[ 0 ],                           // initial value
        DialogDescriptor.BOTTOM_ALIGN,          // options align
        null,                                   // helpCtx
        null );                                 // listener 

    dialogDescriptor.setClosingOptions( new Object[] { options[ 0 ], options[ 1 ] } );
        
    Dialog dialog = DialogDisplayer.getDefault().createDialog( dialogDescriptor );
    dialog.setVisible(true);
    
    return optionsListener.getResult();
}
 
Example 18
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 19
Source File: CustomizerProviderImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override void windowClosing(WindowEvent e) {
    //Dispose the dialog otherwsie the {@link WindowAdapter#windowClosed}
    //may not be called
    Dialog dialog = project2Dialog.get(project);
    if ( dialog != null ) {
        dialog.setVisible(false);
        dialog.dispose();
    }
}
 
Example 20
Source File: ImportDiffAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private static void importDiff(VCSContext ctx) {
    final File roots[] = HgUtils.getActionRoots(ctx);
    if (roots == null || roots.length == 0) return;
    final File root = Mercurial.getInstance().getRepositoryRoot(roots[0]);

    final JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle.getMessage(ImportDiffAction.class, "ACSD_ImportBrowseFolder"), null);   // NO I18N
    fileChooser.setDialogTitle(NbBundle.getMessage(ImportDiffAction.class, "ImportBrowse_title"));                                            // NO I18N
    fileChooser.setMultiSelectionEnabled(false);
    fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    fileChooser.setApproveButtonMnemonic(NbBundle.getMessage(ImportDiffAction.class, "Import").charAt(0));                      // NO I18N
    fileChooser.setApproveButtonText(NbBundle.getMessage(ImportDiffAction.class, "Import"));                                        // NO I18N
    fileChooser.setCurrentDirectory(new File(HgModuleConfig.getDefault().getImportFolder()));
    JPanel panel = new JPanel();
    final JRadioButton asPatch = new JRadioButton(NbBundle.getMessage(ImportDiffAction.class, "CTL_Import_PatchOption")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(asPatch, asPatch.getText()); // NOI18N
    final JRadioButton asBundle = new JRadioButton(NbBundle.getMessage(ImportDiffAction.class, "CTL_Import_BundleOption")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(asBundle, asBundle.getText()); // NOI18N
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(asBundle);
    buttonGroup.add(asPatch);
    asPatch.setSelected(true);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(asPatch);
    panel.add(asBundle);
    fileChooser.setAccessory(panel);

    DialogDescriptor dd = new DialogDescriptor(fileChooser, NbBundle.getMessage(ImportDiffAction.class, "ImportBrowse_title"));              // NO I18N
    dd.setOptions(new Object[0]);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    fileChooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String state = e.getActionCommand();
            if (state.equals(JFileChooser.APPROVE_SELECTION)) {
                final File patchFile = fileChooser.getSelectedFile();

                HgModuleConfig.getDefault().setImportFolder(patchFile.getParent());
                RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root);
                ImportDiffProgressSupport.Kind kind;
                if (asBundle.isSelected()) {
                    kind = ImportDiffProgressSupport.Kind.BUNDLE;
                } else if (asPatch.isSelected()) {
                    kind = ImportDiffProgressSupport.Kind.PATCH;
                } else {
                    kind = null;
                }
                HgProgressSupport support = new ImportDiffProgressSupport(root, patchFile, true, kind);
                support.start(rp, root, org.openide.util.NbBundle.getMessage(ImportDiffAction.class, "LBL_ImportDiff_Progress")); // NOI18N
            }
            dialog.dispose();
        }
    });
    dialog.setVisible(true);
}