java.awt.Dialog#dispose ( )源码实例Demo

下面列出了java.awt.Dialog#dispose ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: CustomizerCompile.java
private void addProcessorButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addProcessorButtonActionPerformed
        final AddAnnotationProcessor panel = new AddAnnotationProcessor();
        final DialogDescriptor desc = new DialogDescriptor(panel, NbBundle.getMessage(CustomizerCompile.class, "LBL_AddAnnotationProcessor_Title")); //NOI18N
        desc.setValid(false);
        panel.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                String fqn = panel.getProcessorFQN();
                desc.setValid(fqn.length() > 0);
            }
        });
        Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
        dlg.setVisible(true);
        if (desc.getValue() == DialogDescriptor.OK_OPTION) {
            ((DefaultListModel)annotationProcessorsList.getModel()).addElement(panel.getProcessorFQN());
        }
        dlg.dispose();
}
 
源代码2 项目: netbeans   文件: LibrariesCustomizer.java
/**
 * Shows libraries customizer for given library manager.
 * @param activeLibrary if not null the activeLibrary is selected in the opened customizer
 * @return true if user pressed OK and libraries were successfully modified
 */
@Messages("TXT_LibrariesManager=Ant Library Manager")
public static boolean showCustomizer (Library activeLibrary, LibraryManager libraryManager) {
    org.netbeans.modules.project.libraries.ui.LibrariesCustomizer  customizer =
            new org.netbeans.modules.project.libraries.ui.LibrariesCustomizer (
                    LibrariesSupport.getLibraryStorageArea(libraryManager));
    customizer.setBorder(new EmptyBorder(12, 12, 0, 12));
    if (activeLibrary != null) {
        customizer.setSelectedLibrary (LibrariesSupport.getLibraryImplementation(activeLibrary));
    }
    DialogDescriptor descriptor = new DialogDescriptor(customizer, TXT_LibrariesManager());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(descriptor);
    setAccessibleDescription(dlg, customizer.getAccessibleContext().getAccessibleDescription());
    try {
        dlg.setVisible(true);
        if (descriptor.getValue() == DialogDescriptor.OK_OPTION) {
            return customizer.apply();
        } else {
            return false;
        }
    } finally {
        dlg.dispose();
    }
}
 
源代码3 项目: netbeans   文件: JspWatchesActionsProvider.java
private static void newWatch () {
    WatchPanel wp = new WatchPanel ("");
    JComponent panel = wp.getPanel ();

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

    if (dd.getValue () != org.openide.DialogDescriptor.OK_OPTION) return;
    DebuggerManager.getDebuggerManager ().createWatch (wp.getExpression ());
}
 
源代码4 项目: netbeans   文件: CustomizerLibraries.java
@Messages("CTL_EditModuleDependencyTitle=Edit Module Dependency")
private void editModuleDependency(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editModuleDependency
    ModuleDependency origDep = getDepListModel().getDependency(
            dependencyList.getSelectedIndex());
    EditDependencyPanel editPanel = new EditDependencyPanel(
            origDep, getProperties().getActivePlatform());
    DialogDescriptor descriptor = new DialogDescriptor(editPanel,
            CTL_EditModuleDependencyTitle());
    descriptor.setHelpCtx(new HelpCtx("org.netbeans.modules.apisupport.project.ui.customizer.EditDependencyPanel"));
    Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
    d.setVisible(true);
    if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
        getDepListModel().editDependency(origDep, editPanel.getEditedDependency());
    }
    d.dispose();
    dependencyList.requestFocusInWindow();
}
 
源代码5 项目: jdk8u-jdk   文件: MultiResolutionSplashTest.java
static float getScaleFactor() {

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

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
 
源代码6 项目: hottub   文件: MultiResolutionSplashTest.java
static float getScaleFactor() {

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

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
 
源代码7 项目: netbeans   文件: WatchesActionsProvider.java
private static void customize (Watch w) {

        WatchPanel wp = new WatchPanel(w.getExpression());
        JComponent panel = wp.getPanel();

        org.openide.DialogDescriptor dd = new org.openide.DialogDescriptor(
            panel,
            NbBundle.getMessage(WatchesActionsProvider.class, "CTL_WatchDialog_Title", // NOI18N 
                                           w.getExpression())
        );
        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());
    }
 
源代码8 项目: netbeans   文件: ManagePluginsAction.java
public void actionPerformed(ActionEvent arg0) {
    GrailsPluginsPanel panel = new GrailsPluginsPanel(project);
    javax.swing.JButton close =
        new javax.swing.JButton(NbBundle.getMessage(ManagePluginsAction.class, "CTL_Close"));
    close.getAccessibleContext()
         .setAccessibleDescription(NbBundle.getMessage(ManagePluginsAction.class, "CTL_Close"));

    DialogDescriptor descriptor =
        new DialogDescriptor(panel, NbBundle.getMessage(ManagePluginsAction.class, "CTL_PluginTitle"),
            true, new Object[] { close }, close, DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx(GrailsPluginsPanel.class), null); // NOI18N
    Dialog dlg = null;

    try {
        dlg = DialogDisplayer.getDefault().createDialog(descriptor);
        dlg.setVisible(true);
    } finally {
        try {
            if (dlg != null) {
                dlg.dispose();
            }
        } finally {
            panel.dispose();
        }
    }
}
 
源代码9 项目: netbeans   文件: ImportHelper.java
private static List<String> showFixImportChooser(Map<String, Set<ImportCandidate>> multipleCandidates) {
    List<String> result = new ArrayList<>();
    ImportChooserInnerPanel panel = new ImportChooserInnerPanel();

    panel.initPanel(multipleCandidates);

    DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(ImportHelper.class, "FixImportsDialogTitle")); //NOI18N
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);

    d.setVisible(true);
    d.setVisible(false);
    d.dispose();

    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
        result = panel.getSelections();
    }
    return result;
}
 
源代码10 项目: dragonwell8_jdk   文件: ModalDialogOrderingTest.java
private static void runTest(Dialog dialog, Frame frame) {
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            sleep();
        }

        Rectangle dialogBounds = dialog.getBounds();
        Rectangle frameBounds = frame.getBounds();

        int y1 = dialogBounds.y + dialogBounds.height;
        int y2 = frameBounds.y + frameBounds.height;

        int clickX = frameBounds.x + frameBounds.width / 2;
        int clickY = y1 + (y2 - y1) / 2;

        robot.mouseMove(clickX, clickY);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        sleep();

        int colorX = dialogBounds.x + dialogBounds.width / 2;
        int colorY = dialogBounds.y + dialogBounds.height / 2;

        Color color = robot.getPixelColor(colorX, colorY);

        dialog.dispose();
        frame.dispose();

        if (!DIALOG_COLOR.equals(color)) {
            throw new RuntimeException("The frame is on top"
                    + " of the modal dialog!");
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
源代码11 项目: netbeans   文件: CustomizerProviderImpl.java
@Override
public void windowClosing(WindowEvent e) {
    // dispose the dialog otherwise {@link WindowAdapter#windowClosed} may not be called
    Dialog dialog = PROJECT_2_DIALOG.get(project);
    if (dialog != null) {
        dialog.setVisible(false);
        dialog.dispose();
    }
}
 
源代码12 项目: dragonwell8_jdk   文件: DialogAboveFrameTest.java
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame frame = new Frame("Frame");
    frame.setBackground(Color.BLUE);
    frame.setBounds(200, 50, 300, 300);
    frame.setVisible(true);

    Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
    dialog1.setBackground(Color.RED);
    dialog1.setBounds(100, 100, 200, 200);
    dialog1.setVisible(true);

    Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
    dialog2.setBackground(Color.GREEN);
    dialog2.setBounds(400, 100, 200, 200);
    dialog2.setVisible(true);

    Util.waitForIdle(robot);

    Util.clickOnComp(dialog2, robot);
    Util.waitForIdle(robot);

    Point point = dialog1.getLocationOnScreen();
    int x = point.x + (int)(dialog1.getWidth() * 0.9);
    int y = point.y + (int)(dialog1.getHeight() * 0.9);

    try {
        if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
            throw new RuntimeException("Test FAILED: Dialog is behind the frame");
        }
    } finally {
        frame.dispose();
        dialog1.dispose();
        dialog2.dispose();
    }
}
 
源代码13 项目: netbeans   文件: CustomizerProviderImpl.java
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();
    }
}
 
源代码14 项目: TencentKona-8   文件: DialogAboveFrameTest.java
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame frame = new Frame("Frame");
    frame.setBackground(Color.BLUE);
    frame.setBounds(200, 50, 300, 300);
    frame.setVisible(true);

    Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
    dialog1.setBackground(Color.RED);
    dialog1.setBounds(100, 100, 200, 200);
    dialog1.setVisible(true);

    Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
    dialog2.setBackground(Color.GREEN);
    dialog2.setBounds(400, 100, 200, 200);
    dialog2.setVisible(true);

    Util.waitForIdle(robot);

    Util.clickOnComp(dialog2, robot);
    Util.waitForIdle(robot);

    Point point = dialog1.getLocationOnScreen();
    int x = point.x + (int)(dialog1.getWidth() * 0.9);
    int y = point.y + (int)(dialog1.getHeight() * 0.9);

    try {
        if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
            throw new RuntimeException("Test FAILED: Dialog is behind the frame");
        }
    } finally {
        frame.dispose();
        dialog1.dispose();
        dialog2.dispose();
    }
}
 
源代码15 项目: jdk8u60   文件: ModalDialogOrderingTest.java
private static void runTest(Dialog dialog, Frame frame) {
    try {
        Robot robot = new Robot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            sleep();
        }

        Rectangle dialogBounds = dialog.getBounds();
        Rectangle frameBounds = frame.getBounds();

        int y1 = dialogBounds.y + dialogBounds.height;
        int y2 = frameBounds.y + frameBounds.height;

        int clickX = frameBounds.x + frameBounds.width / 2;
        int clickY = y1 + (y2 - y1) / 2;

        robot.mouseMove(clickX, clickY);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        sleep();

        int colorX = dialogBounds.x + dialogBounds.width / 2;
        int colorY = dialogBounds.y + dialogBounds.height / 2;

        Color color = robot.getPixelColor(colorX, colorY);

        dialog.dispose();
        frame.dispose();

        if (!DIALOG_COLOR.equals(color)) {
            throw new RuntimeException("The frame is on top"
                    + " of the modal dialog!");
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
源代码16 项目: netbeans   文件: JFXDeploymentPanel.java
private void buttonSigningActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSigningActionPerformed
    JFXSigningPanel panel = new JFXSigningPanel(jfxProps);
    DialogDescriptor dialogDesc = new DialogDescriptor(panel, NbBundle.getMessage(JFXSigningPanel.class, "TITLE_JFXSigningPanel"), true, null); // NOI18N
    panel.registerListeners();
    panel.setDialogDescriptor(dialogDesc);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDesc);
    dialog.setVisible(true);
    if (dialogDesc.getValue() == DialogDescriptor.OK_OPTION) {
        panel.store();
        refreshSigningLabel();
    }
    panel.unregisterListeners();
    dialog.dispose();
}
 
源代码17 项目: netbeans   文件: ProjectCustomizerProvider.java
@Override
        public void actionPerformed( ActionEvent e ) {
//#95952 some users experience this assertion on a fairly random set of changes in 
// the customizer, that leads me to assume that a project can be already marked
// as modified before the project customizer is shown. 
//            assert !ProjectManager.getDefault().isModified(project) : 
//                "Some of the customizer panels has written the changed data before OK Button was pressed. Please file it as bug."; //NOI18N
            
            // Close & dispose the the dialog
            Dialog dialog = project2Dialog.get( project );
            if ( dialog != null ) {
                dialog.setVisible(false);
                dialog.dispose();
            }
        }
 
源代码18 项目: netbeans   文件: ReferencesPanel.java
public static URL showInWindow() {
    JButton openBtn = new JButton();
    Mnemonics.setLocalizedText(openBtn, NbBundle.getMessage(ReferencesPanel.class, "ReferencesPanel.ok.text"));
    openBtn.getAccessibleContext().setAccessibleDescription(openBtn.getText());
    openBtn.setEnabled(false);

    final Object[] buttons = new Object[] { openBtn, DialogDescriptor.CANCEL_OPTION };

    ReferencesPanel panel = new ReferencesPanel(openBtn);
    DialogDescriptor desc = new DialogDescriptor(
            panel,
            NbBundle.getMessage(ReferencesPanel.class, "ReferencesPanel.title"),
            true,
            buttons,
            openBtn,
            DialogDescriptor.DEFAULT_ALIGN,
            HelpCtx.DEFAULT_HELP,
            null);
    desc.setClosingOptions(buttons);

    Dialog dialog = DialogDisplayer.getDefault().createDialog(desc);
    dialog.getAccessibleContext().setAccessibleName(NbBundle.getMessage(ReferencesPanel.class, "AN_ReferencesDialog"));
    dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ReferencesPanel.class, "AD_ReferencesDialog"));

    // schedule computing indices
    RP.post(panel);
    dialog.setVisible(true);
    dialog.dispose();

    return desc.getValue() == openBtn
            ? panel.getSelectedItem()
            : null;
}
 
源代码19 项目: netbeans   文件: AddServerInstanceWizard.java
public static String showAddServerInstanceWizard(Map<String, String> props) {
    Collection<Server> allServers = ServerRegistry.getInstance().getServers();
    for (java.util.Iterator<Server> it = allServers.iterator(); it.hasNext();) {
        Server server = it.next();
        OptionalDeploymentManagerFactory factory = server.getOptionalFactory();
        if (factory == null || factory.getAddInstanceIterator() == null) {
            it.remove();
        }
    }
    if (allServers.isEmpty()) {
        // display the warning dialog - no server plugins
        String close = NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Close");
        DialogDescriptor descriptor = new DialogDescriptor(
                NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Text"),
                NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Title"),
                true,
                new Object[] {close},
                close,
                DialogDescriptor.DEFAULT_ALIGN,
                null,
                null);

        // TODO invoke plugin manager once API to do that will be available
        DialogDisplayer.getDefault().notify(descriptor);
        return null;
    }
        
    AddServerInstanceWizard wizard = new AddServerInstanceWizard(props);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizard);
    try {
        dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddServerInstanceWizard.class, "ACSD_Add_Server_Instance"));
        dialog.setVisible(true);
    } finally {
        dialog.dispose();
    }
    if (wizard.getValue() == WizardDescriptor.FINISH_OPTION) {
        Set instantiatedObjects = wizard.getInstantiatedObjects();
        if (instantiatedObjects != null && instantiatedObjects.size() > 0) {
            Object result = instantiatedObjects.iterator().next();
            if (result instanceof InstanceProperties) {
                return ((InstanceProperties) result).getProperty(InstanceProperties.URL_ATTR);
            } else {
                LOGGER.warning(wizard.iterator.getSelectedServer() + "'s add server instance wizard iterator should return " + // NOI18N
                        "a Set containing new server instance InstanceProperties object as a result of the " + // NOI18N
                        "WizardDescriptor.InstantiatingIterator.instantiate() method."); // NOI18N
                // there is an error in the server plugin, cannot return the added instance
                return null;
            }
        }
    }
    // the wizard was cancelled
    return null;
}
 
源代码20 项目: openjdk-jdk9   文件: ModalDialogOrderingTest.java
private static void runTest(Dialog dialog, Frame frame) {
    try {
        ExtendedRobot robot = new ExtendedRobot();
        robot.setAutoDelay(50);
        robot.mouseMove(300, 300);

        while (!dialog.isVisible()) {
            robot.waitForIdle(1000);
        }

        Rectangle dialogBounds = dialog.getBounds();
        Rectangle frameBounds = frame.getBounds();

        int y1 = dialogBounds.y + dialogBounds.height;
        int y2 = frameBounds.y + frameBounds.height;

        int clickX = frameBounds.x + frameBounds.width / 2;
        int clickY = y1 + (y2 - y1) / 2;

        robot.mouseMove(clickX, clickY);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        robot.waitForIdle(1000);

        int colorX = dialogBounds.x + dialogBounds.width / 2;
        int colorY = dialogBounds.y + dialogBounds.height / 2;

        Color color = robot.getPixelColor(colorX, colorY);


        if (!DIALOG_COLOR.equals(color)) {
            throw new RuntimeException("The frame is on top"
                    + " of the modal dialog!");
        }else{
            frame.dispose();
            dialog.dispose();
        }
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}