当前位置: 首页>>代码示例>>Java>>正文


Java Dialog.addWindowListener方法代码示例

本文整理汇总了Java中java.awt.Dialog.addWindowListener方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.addWindowListener方法的具体用法?Java Dialog.addWindowListener怎么用?Java Dialog.addWindowListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Dialog的用法示例。


在下文中一共展示了Dialog.addWindowListener方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: openBrandingEditor

import java.awt.Dialog; //导入方法依赖的package包/类
/**
 * Opens branding editor for given project. Must be invoked from EDT.
 * @param displayName Editor's display name.
 * @param p Project to be branded.
 * @param model a branding model to use
 */
public static void openBrandingEditor(String displayName, final Project p, BrandingModel model) {
    if( !SwingUtilities.isEventDispatchThread() ) {
        throw new IllegalStateException("This method must be invoked from EDT."); //NOI18N
    }
    synchronized( project2dialog ) {
        Dialog dlg = project2dialog.get(p);
        if( null == dlg ) {
            BrandingEditorPanel editor = new BrandingEditorPanel(displayName, model);
            dlg = editor.open();
            project2dialog.put(p, dlg);
            dlg.addWindowListener( new WindowAdapter() {
                @Override public void windowClosed(WindowEvent e) {
                    synchronized( project2dialog ) {
                        project2dialog.remove(p);
                    }
                }
            });
        } else {
            dlg.setVisible(true);
            dlg.requestFocusInWindow();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:BrandingUtils.java

示例2: open

import java.awt.Dialog; //导入方法依赖的package包/类
public boolean open () {
    dd = new DialogDescriptor(panel, NbBundle.getMessage(RevisionPicker.class, "LBL_RevisionPickerDialog.title"), //NOI18N
            true, new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx("org.netbeans.modules.git.ui.repository.RevisionPickerDialog"), null); //NOI18N
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    updateDialogState();
    browserPanel.addPropertyChangeListener(this);
    Preferences prefs = GitModuleConfig.getDefault().getPreferences();
    WindowListener windowListener = new DialogBoundsPreserver(prefs, this.getClass().getName());
    dialog.addWindowListener(windowListener);
    windowListener.windowOpened(new WindowEvent(dialog, WindowEvent.WINDOW_OPENED));
    dialog.pack();
    updateSliders(prefs);
    dialog.setVisible(true);
    persistSliders(prefs);
    browserPanel.removePropertyChangeListener(this);
    return dd.getValue() == okButton;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RevisionPicker.java

示例3: bindFrameViewerToCurrentDialog

import java.awt.Dialog; //导入方法依赖的package包/类
/**
 * If the help frame is opened from a modal dialog, it should be closed
 * automatically if that dialog closes. See bug 233543. Also the windows
 * should be rearranged so that both are visible. See bug #233542.
 */
private void bindFrameViewerToCurrentDialog() {
    int maxDepth = 0;
    Dialog topDialog = null;
    for (Window w : JDialog.getWindows()) {
        if (w instanceof Dialog && w.isVisible()) {
            Dialog d = (Dialog) w;
            if (isRelevantDialog(d)) {
                int depth = 0;
                for (Window o = d.getOwner(); o != null; o = o.getOwner()) {
                    depth++;
                    if (o == WindowManager.getDefault().getMainWindow()
                            && depth > maxDepth) {
                        maxDepth = depth;
                        topDialog = d;
                        break;
                    }
                }
            }
        }
    }
    if (topDialog != null) {
        rearrange(topDialog, frameViewer);
        final Dialog finalTopDialog = topDialog;
        topDialog.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosed(WindowEvent e) {
                if (frameViewer != null) {
                    frameViewer.setVisible(false);
                }
                finalTopDialog.removeWindowListener(this);
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:JavaHelp.java

示例4: show

import java.awt.Dialog; //导入方法依赖的package包/类
/**
 * Shows a dialog listing all given versioning info properties.
 * @param properties
 */
public static void show (HashMap<File, Map<String, String>> properties) {
    PropertySheet ps = new PropertySheet();
    ps.setNodes(new VersioningInfoNode[] {new VersioningInfoNode(properties)});
    DialogDescriptor dd = new DialogDescriptor(ps, NbBundle.getMessage(VersioningInfo.class, "MSG_VersioningInfo_title"), //NOI18N
            true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.addWindowListener(new DialogBoundsPreserver(NbPreferences.forModule(VersioningInfo.class), "versioning.util.versioningInfo")); //NOI18N
    dialog.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:VersioningInfo.java

示例5: showCustomizer

import java.awt.Dialog; //导入方法依赖的package包/类
@Override
@NbBundle.Messages("MSG_CustomizerForbidden=The customizer is disabled, using it would revert manual changes done to the nbproject/project.xml file.")
public void showCustomizer() {
    AuxiliaryProperties props = project.getLookup().lookup(AuxiliaryProperties.class);
    String show = props.get("show.customizer", true);
    if (show != null && "false".equals(show)) {
        String message = props.get("show.customizer.message", true);
        if (message == null) {
            message = MSG_CustomizerForbidden();
        }
        NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.WARNING_MESSAGE);
        DialogDisplayer.getDefault().notify(nd);
        return;
    }
    Dialog dialog = project2Dialog.get (project);
    if ( dialog != null ) {            
        dialog.setVisible(true);
    }
    else {
        InstanceContent ic = new InstanceContent();
        Lookup context = new AbstractLookup(ic);
        ic.add(project);
        ic.add(project.getLookup().lookup(ProjectAccessor.class));
        ic.add(project.getLookup().lookup(AuxiliaryConfiguration.class));
        //TODO replace with generic apis..
        ic.add(ic);
        
        OptionListener listener = new OptionListener();
        dialog = ProjectCustomizer.createCustomizerDialog(CUSTOMIZER_FOLDER_PATH, context, null, listener, null );
        dialog.addWindowListener( listener );
        dialog.setTitle( MessageFormat.format(                 
                NbBundle.getMessage( ProjectCustomizerProvider.class, "LBL_Customizer_Title" ), // NOI18N 
                new Object[] { ProjectUtils.getInformation(project).getDisplayName() } ) );

        project2Dialog.put(project, dialog);
        dialog.setVisible(true);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ProjectCustomizerProvider.java

示例6: showDialog

import java.awt.Dialog; //导入方法依赖的package包/类
private void showDialog(DialogDescriptor dialogDescriptor, HelpCtx helpCtx, String name) {
    dialogDescriptor.setModal(true);
    dialogDescriptor.setHelpCtx(helpCtx);        

    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);        
    if (name != null) {
        dialog.addWindowListener(new DialogBoundsPreserver(HgModuleConfig.getDefault().getPreferences(), name)); // NOI18N
    }
    dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(Repository.class, "ACSD_RepositoryPanel"));

    dialog.setVisible(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:Repository.java

示例7: customize

import java.awt.Dialog; //导入方法依赖的package包/类
boolean customize(final ValidityAwarePanel customizer, Runnable updater, boolean focusToEditor) {
    ValidityAwarePanel showingCustomizer = getShowingCustomizer();

    if (showingCustomizer != null) {
        ProfilerDialogs.displayWarning(
                Bundle.ProfilingPointsManager_AnotherPpEditedMsg());
        SwingUtilities.getWindowAncestor(showingCustomizer).requestFocus();
        showingCustomizer.requestFocusInWindow();
    } else {
        CustomizerButton cb = getCustomizerButton();
        customizer.addValidityListener(cb);
        cb.setEnabled(customizer.areSettingsValid()); // In fact customizer should be valid but just to be sure...

        JPanel customizerContainer = new JPanel(new BorderLayout());
        JPanel customizerSpacer = new JPanel(new BorderLayout());
        customizerSpacer.setBorder(BorderFactory.createEmptyBorder(0, 0, 20, 0));
        customizerSpacer.add(customizer, BorderLayout.CENTER);
        customizerContainer.add(customizerSpacer, BorderLayout.CENTER);
        customizerContainer.add(new JSeparator(), BorderLayout.SOUTH);

        HelpCtx helpCtx = null;

        if (customizer instanceof HelpCtx.Provider) {
            helpCtx = ((HelpCtx.Provider) customizer).getHelpCtx();
        }

        DialogDescriptor dd = new DialogDescriptor(customizerContainer, Bundle.ProfilingPointsManager_PpCustomizerCaption(), false,
                                                   new Object[] { cb, DialogDescriptor.CANCEL_OPTION },
                                                   cb, 0, helpCtx, null);
        final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
        d.addWindowListener(new CustomizerListener(d, dd, updater));
        d.setModal(true);
        // give focus to the initial focus target
        d.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                if (customizer.getInitialFocusTarget() != null) {
                    customizer.getInitialFocusTarget().requestFocusInWindow();
                }
            }
        });
        
        if (focusToEditor) {
            Dimension dim = d.getPreferredSize();
            Component masterComponent = WindowManager.getDefault().getRegistry().getActivated();
            if (masterComponent != null) {
                Rectangle b = masterComponent.getBounds();
                Point location = new Point((b.x + (b.width / 2)) - (dim.width / 2),
                                           (b.y + (b.height / 2)) - (dim.height / 2));
                SwingUtilities.convertPointToScreen(location, masterComponent);
                d.setLocation(location);
            }
        }
        
        d.setVisible(true);
        
        if (dd.getValue() == cb) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:63,代码来源:ProfilingPointsManager.java

示例8: createDialog

import java.awt.Dialog; //导入方法依赖的package包/类
static Dialog createDialog(
        final String title,
        final GoToPanelImpl panel,
        final GoToPanelImpl.ContentProvider contentProvider,
        final JButton okButton) {
    okButton.setEnabled (false);
    panel.getAccessibleContext().setAccessibleName( NbBundle.getMessage( GoToSymbolAction.class, "AN_GoToSymbol")  ); //NOI18N
    panel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage( GoToSymbolAction.class, "AD_GoToSymbol")  ); //NOI18N

    DialogDescriptor dialogDescriptor = new DialogDescriptor(
        panel,                             // innerPane
        title, // displayName
        true,
        new Object[] {okButton, DialogDescriptor.CANCEL_OPTION},
        okButton,
        DialogDescriptor.DEFAULT_ALIGN,
        HelpCtx.DEFAULT_HELP,
        new DialogButtonListener(panel, okButton));

     dialogDescriptor.setClosingOptions(new Object[] {okButton, DialogDescriptor.CANCEL_OPTION});


    Dialog d = DialogDisplayer.getDefault().createDialog( dialogDescriptor );

    // Set size when needed
    final int width = UiOptions.GoToSymbolDialog.getWidth();
    final int height = UiOptions.GoToSymbolDialog.getHeight();
    if (width != -1 && height != -1) {
        d.setPreferredSize(new Dimension(width,height));
    }

    // Center the dialog after the size changed.
    Rectangle r = Utilities.getUsableScreenBounds();
    int maxW = (r.width * 9) / 10;
    int maxH = (r.height * 9) / 10;
    final Dimension dim = d.getPreferredSize();
    dim.width = Math.min(dim.width, maxW);
    dim.height = Math.min(dim.height, maxH);
    d.setBounds(Utilities.findCenterBounds(dim));
    initialDimension = dim;
    d.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            contentProvider.closeDialog();
        }
    });

    return d;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:DialogFactory.java

示例9: createDialog

import java.awt.Dialog; //导入方法依赖的package包/类
private Dialog createDialog( final FileSearchPanel panel) {
    openBtn = new JButton();
    Mnemonics.setLocalizedText(openBtn, NbBundle.getMessage(FileSearchAction.class, "CTL_Open"));
    openBtn.getAccessibleContext().setAccessibleDescription(openBtn.getText());
    openBtn.setEnabled( false );

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

    String title = NbBundle.getMessage(FileSearchAction.class, "MSG_FileSearchDlgTitle");
    DialogDescriptor dialogDescriptor = new DialogDescriptor(
            panel,
            title,
            true,
            buttons,
            openBtn,
            DialogDescriptor.DEFAULT_ALIGN,
            HelpCtx.DEFAULT_HELP,
            new DialogButtonListener(panel));
    dialogDescriptor.setClosingOptions(buttons);

    Dialog d = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
    d.getAccessibleContext().setAccessibleName(NbBundle.getMessage(FileSearchAction.class, "AN_FileSearchDialog"));
    d.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FileSearchAction.class, "AD_FileSearchDialog"));

    // Set size
    d.setPreferredSize( new Dimension(  FileSearchOptions.getWidth(),
                                             FileSearchOptions.getHeight() ) );

    // Center the dialog after the size changed.
    Rectangle r = Utilities.getUsableScreenBounds();
    int maxW = (r.width * 9) / 10;
    int maxH = (r.height * 9) / 10;
    Dimension dim = d.getPreferredSize();
    dim.width = Math.min(dim.width, maxW);
    dim.height = Math.min(dim.height, maxH);
    initialDimension = dim;
    d.setBounds(Utilities.findCenterBounds(dim));
    d.addWindowListener(new WindowAdapter() {
        public @Override void windowClosed(WindowEvent e) {
            cleanup(false);
        }
    });

    return d;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:FileSearchAction.java

示例10: createDialog

import java.awt.Dialog; //导入方法依赖的package包/类
/** Creates the dialog to show
     */
   private Dialog createDialog( final GoToPanel panel) {

        okButton = new JButton (NbBundle.getMessage(GoToTypeAction.class, "CTL_OK"));
        okButton.getAccessibleContext().setAccessibleDescription(okButton.getText());
        okButton.setEnabled (false);
        panel.getAccessibleContext().setAccessibleName( NbBundle.getMessage( GoToTypeAction.class, "AN_GoToType") ); //NOI18N
        panel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage( GoToTypeAction.class, "AD_GoToType") ); //NOI18N

        DialogDescriptor dialogDescriptor = new DialogDescriptor(
            panel,                             // innerPane
            title, // displayName
            true,
            new Object[] {okButton, DialogDescriptor.CANCEL_OPTION},
            okButton,
            DialogDescriptor.DEFAULT_ALIGN,
            HelpCtx.DEFAULT_HELP,
            new DialogButtonListener( panel ) );                                 // Action listener

         dialogDescriptor.setClosingOptions(new Object[] {okButton, DialogDescriptor.CANCEL_OPTION});

        // panel.addPropertyChangeListener( new HelpCtxChangeListener( dialogDescriptor, helpCtx ) );
//        if ( panel instanceof HelpCtx.Provider ) {
//            dialogDescriptor.setHelpCtx( ((HelpCtx.Provider)panel).getHelpCtx() );
//        }

        Dialog d = DialogDisplayer.getDefault().createDialog( dialogDescriptor );

        // Set size when needed
        final int width = UiOptions.GoToTypeDialog.getWidth();
        final int height = UiOptions.GoToTypeDialog.getHeight();
        if (width != -1 && height != -1) {
            d.setPreferredSize(new Dimension(width,height));
        }

        // Center the dialog after the size changed.
        Rectangle r = Utilities.getUsableScreenBounds();
        int maxW = (r.width * 9) / 10;
        int maxH = (r.height * 9) / 10;
        final Dimension dim = d.getPreferredSize();
        dim.width = Math.min(dim.width, maxW);
        dim.height = Math.min(dim.height, maxH);
        d.setBounds(Utilities.findCenterBounds(dim));
        initialDimension = dim;
        d.addWindowListener(new WindowAdapter() {
            public @Override void windowClosed(WindowEvent e) {
                cleanup();
            }
        });

        return d;

    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:55,代码来源:GoToTypeAction.java


注:本文中的java.awt.Dialog.addWindowListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。