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

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

源代码1 项目: visualvm   文件: ValuesCustomizer.java
static String customize(final ValuesCustomizer customizer, String selectedValues) {
    customizer.init(selectedValues);

    final DialogDescriptor dd = new DialogDescriptor(customizer,
                                customizer.dialogTitle(), true, null);
    final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    SwingUtilities.invokeLater(new Runnable() {
        public void run() { customizer.onShown(); }
    });
    d.setVisible(true);

    String result = dd.getValue() != DialogDescriptor.OK_OPTION ? null :
                                     customizer.getSelectedCipherSuites();
    customizer.cleanup();
    return result;
}
 
源代码2 项目: netbeans   文件: AttachDialog.java
private static void showDetails(RunningVM vm) {
    HTMLTextArea area = new HTMLTextArea();
    JScrollPane areaScroll = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                                   JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    areaScroll.setBorder(BorderFactory.createEmptyBorder());
    areaScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    areaScroll.setPreferredSize(new Dimension(500, 260));
    configureScrollBar(areaScroll.getVerticalScrollBar());
    configureScrollBar(areaScroll.getHorizontalScrollBar());
    
    area.setText(getDetails(vm));
    area.setCaretPosition(0);
    
    HelpCtx helpCtx = new HelpCtx("ProcessDetails.HelpCtx"); //NOI18N
    JButton close = new JButton(Bundle.AttachDialog_BtnClose());
    close.setDefaultCapable(true);
    DialogDescriptor dd = new DialogDescriptor(areaScroll, Bundle.AttachDialog_DetailsCaption(getProcessName(vm.getMainClass())),
                          true, new Object[] { close }, close, DialogDescriptor.DEFAULT_ALIGN, helpCtx, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);
}
 
源代码3 项目: visualvm   文件: PropertiesConfigurator.java
public static void editProperties(DataSource dataSource, int propertiesCategory) {
    PropertiesCustomizer customizer =
            PropertiesSupport.sharedInstance().getCustomizer(dataSource, null);
    customizer.selectCategory(propertiesCategory);
    PropertiesConfigurator pc = new PropertiesConfigurator(customizer);

    final DialogDescriptor dd = new DialogDescriptor(pc, NbBundle.getMessage(
            PropertiesConfigurator.class, "CAP_EditProperties", new Object[] { // NOI18N
            DataSourceDescriptorFactory.getDescriptor(dataSource).getName() }),
            true, new Object[] { pc.okButton, DialogDescriptor.CANCEL_OPTION },
            pc.okButton, 0, null, null);
    final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    String className = dataSource.getClass().getName();
    Dimension savedSize = SAVED_SIZES.get(className);
    if (savedSize != null) pc.setPreferredSize(savedSize);
    d.pack();
    d.setVisible(true);
    SAVED_SIZES.put(className, pc.getSize());
    pc.cleanup();

    if (dd.getValue() == pc.okButton) customizer.propertiesChanged();
    else customizer.propertiesCancelled();
}
 
/**
 * Show the "Resolve Data Sources" dialog and let the user choose a datasource from
 * the list.
 *
 * @param title dialog title
 * @param description dialog accessible description
 * @param project
 * 
 *
 */
public static void selectDatasources(String title, String description, Project project) {
    MissingDatabaseConnectionWarning panel = new MissingDatabaseConnectionWarning(project);
    Object[] options = new Object[] {
        DialogDescriptor.CLOSED_OPTION
    };
    final DialogDescriptor desc = new DialogDescriptor(panel, title, true, options,
            DialogDescriptor.CLOSED_OPTION, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(MissingDatabaseConnectionWarning.class), null);
    desc.setMessageType(DialogDescriptor.WARNING_MESSAGE);
    Dialog dlg = null;
    try {
        dlg = DialogDisplayer.getDefault().createDialog(desc);
        dlg.getAccessibleContext().setAccessibleDescription(description);            
        desc.setValid(panel.getSelectedDatasource() != null);
        panel.setSize(panel.getPreferredSize());
        dlg.pack();
        dlg.setVisible(true);
    } finally {
        if (dlg != null) {
            dlg.dispose();
        }
    }
}
 
源代码5 项目: netbeans   文件: RevisionPicker.java
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;
}
 
源代码6 项目: visualvm   文件: AttachDialog.java
private static void showDetails(RunningVM vm) {
    HTMLTextArea area = new HTMLTextArea();
    JScrollPane areaScroll = new JScrollPane(area, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                                   JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    areaScroll.setBorder(BorderFactory.createEmptyBorder());
    areaScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    areaScroll.setPreferredSize(new Dimension(500, 260));
    configureScrollBar(areaScroll.getVerticalScrollBar());
    configureScrollBar(areaScroll.getHorizontalScrollBar());
    
    area.setText(getDetails(vm));
    area.setCaretPosition(0);
    
    HelpCtx helpCtx = new HelpCtx("ProcessDetails.HelpCtx"); //NOI18N
    JButton close = new JButton(Bundle.AttachDialog_BtnClose());
    close.setDefaultCapable(true);
    DialogDescriptor dd = new DialogDescriptor(areaScroll, Bundle.AttachDialog_DetailsCaption(getProcessName(vm.getMainClass())),
                          true, new Object[] { close }, close, DialogDescriptor.DEFAULT_ALIGN, helpCtx, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);
}
 
源代码7 项目: visualvm   文件: AnalysisControllerUI.java
public static void showDescription(Rule rule, String htmlDescription) {
    Class ruleClass = rule.getClass();
    URL ruleBase = ruleClass.getResource(ruleClass.getSimpleName() + ".class"); // NOI18N
    final DialogDescriptor dd = new DialogDescriptor(new DescriptionDisplayer(ruleBase, htmlDescription),
                                                     rule.getDisplayName(), true,
                                                     new Object[] { DialogDescriptor.OK_OPTION },
                                                     DialogDescriptor.OK_OPTION, DialogDescriptor.BOTTOM_ALIGN, null, null);
    final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack(); // allows correct resizing of textarea in PreferredInstrFilterPanel
    d.setVisible(true);
}
 
源代码8 项目: netbeans   文件: ProfilingPointsDisplayer.java
public static void displayProfilingPoints(Lookup.Provider project, ProfilingSettings settings) {
    ProfilingPointsDisplayer ppd = getDefault();
    ppd.setupDisplay(project, settings);

    final DialogDescriptor dd = new DialogDescriptor(ppd,
                                                     Bundle.ProfilingPointsDisplayer_PpActiveMsg(settings.getSettingsName()), 
                                                     true,
                                                     new Object[] { DialogDescriptor.OK_OPTION }, DialogDescriptor.OK_OPTION,
                                                     0, null, null);
    final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);

    ppd.cleanup();
}
 
源代码9 项目: visualvm   文件: HostCustomizer.java
public static HostProperties defineHost() {
  HostCustomizer hc = getInstance();
  hc.setup();

  ScrollableContainer sc = new ScrollableContainer(hc,
          ScrollableContainer.VERTICAL_SCROLLBAR_AS_NEEDED,
          ScrollableContainer.HORIZONTAL_SCROLLBAR_NEVER);
  sc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  sc.setViewportBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  
  final DialogDescriptor dd = new DialogDescriptor(sc, NbBundle.getMessage(
          HostCustomizer.class, "Title_Add_Remote_Host"), true, new Object[] {   // NOI18N
          hc.okButton, DialogDescriptor.CANCEL_OPTION }, hc.okButton, 0, null, null);
  dd.setAdditionalOptions(new Object[] { hc.settingsButton });
  final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
  d.pack();
  d.setVisible(true);

  if (dd.getValue() == hc.okButton) {
      HostProperties hp = new HostProperties(hc.getHostName(), hc.getDisplayName(),
                                             hc.getPropertiesCustomizer());
      hc.accepted();
      return hp;
  } else {
      hc.cancelled();
      return null;
  }
}
 
源代码10 项目: opensim-gui   文件: DialogUtils.java
public static void addCloseButton(Dialog dDialog, ActionListener actionListener) {
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createRigidArea(new Dimension(50, 50)));
    buttonPanel.add(Box.createVerticalStrut(50));
    buttonPanel.add(Box.createGlue());
    dDialog.add(buttonPanel, BorderLayout.SOUTH);
    JButton closeButton = new JButton("Close");
    buttonPanel.add(closeButton);
    closeButton.addActionListener(actionListener);
    dDialog.doLayout();
    dDialog.pack();
}
 
源代码11 项目: netbeans   文件: NoSelectedServerWarning.java
public static String selectServerDialog(J2eeModule.Type[] moduleTypes, Profile j2eeProfile, String title, String description) {
    NoSelectedServerWarning panel = new NoSelectedServerWarning(moduleTypes, j2eeProfile);
    Object[] options = new Object[] {
        DialogDescriptor.OK_OPTION,
        DialogDescriptor.CANCEL_OPTION
    };
    final DialogDescriptor desc = new DialogDescriptor(panel, title, true, options,
            DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, null, null);
    desc.setMessageType(DialogDescriptor.WARNING_MESSAGE);
    Dialog dlg = null;
    try {
        dlg = DialogDisplayer.getDefault().createDialog(desc);
        dlg.getAccessibleContext().setAccessibleDescription(description);
        panel.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals(NoSelectedServerWarning.OK_ENABLED)) {
                    Object newvalue = evt.getNewValue();
                    if ((newvalue != null) && (newvalue instanceof Boolean)) {
                        desc.setValid(((Boolean)newvalue).booleanValue());
                    }
                }
            }
        }
        );
        desc.setValid(panel.getSelectedInstance() != null);
        panel.setSize(panel.getPreferredSize());
        dlg.pack();
        dlg.setVisible(true);
    } finally {
        if (dlg != null) {
            dlg.dispose();
        }
    }
    return desc.getValue() == DialogDescriptor.OK_OPTION
            ? panel.getSelectedInstance()
            : null;
}
 
源代码12 项目: netbeans   文件: SvnPropertiesAction.java
public static void openProperties(File[] roots, String ctxDisplayName) {
    if(!Subversion.getInstance().checkClientAvailable()) {            
        return;
    }       

    final PropertiesPanel panel = new PropertiesPanel();
    final PropertiesTable propTable;
    propTable = new PropertiesTable(panel.labelForTable, PropertiesTable.PROPERTIES_COLUMNS, new String[] { PropertiesTableModel.COLUMN_NAME_VALUE});
    panel.setPropertiesTable(propTable);

    JComponent component = propTable.getComponent();
    panel.propsPanel.setLayout(new BorderLayout());
    panel.propsPanel.add(component, BorderLayout.CENTER);
    SvnProperties svnProperties = new SvnProperties(panel, propTable, roots);
    JButton btnClose = new JButton();
    Mnemonics.setLocalizedText(btnClose, getString("CTL_Properties_Action_Close"));   //NOI18N
    btnClose.getAccessibleContext().setAccessibleDescription(getString("CTL_Properties_Action_Close")); //NOI18N
    btnClose.getAccessibleContext().setAccessibleName(getString("CTL_Properties_Action_Close"));    //NOI18N

    DialogDescriptor dd = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(SvnPropertiesAction.class, "CTL_PropertiesDialog_Title", ctxDisplayName)); // NOI18N
    dd.setModal(true);
    dd.setOptions(new Object[] {btnClose});
    dd.setHelpCtx(new HelpCtx(SvnPropertiesAction.class));

    panel.putClientProperty("contentTitle", ctxDisplayName);  // NOI18N
    panel.putClientProperty("DialogDescriptor", dd); // NOI18N
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SvnPropertiesAction.class, "CTL_PropertiesAction")); // NOI18N
    dialog.pack();
    dialog.setVisible(true);        
}
 
源代码13 项目: opensim-gui   文件: ObjectDisplayOpacityPanel.java
void showDialog() {
   DialogDescriptor dlg = new DialogDescriptor(this, "Select Opacity");
   dlg.setOptions(new Object[]{});
   Dialog dialog = DialogDisplayer.getDefault().createDialog(dlg);
   dialog.pack();
   dialog.setVisible(true);
}
 
源代码14 项目: netbeans   文件: MercurialOptionsPanelController.java
private void onManageClick() {
    final PropertiesPanel panel = new PropertiesPanel();

    final PropertiesTable propTable;

    propTable = new PropertiesTable(panel.labelForTable, PropertiesTable.PROPERTIES_COLUMNS, new String[] { PropertiesTableModel.COLUMN_NAME_VALUE});

    panel.setPropertiesTable(propTable);

    JComponent component = propTable.getComponent();

    panel.propsPanel.setLayout(new BorderLayout());

    panel.propsPanel.add(component, BorderLayout.CENTER);

    HgExtProperties hgProperties = new HgExtProperties(panel, propTable, null) ;

    final JButton okButton =  new JButton(NbBundle.getMessage(MercurialOptionsPanelController.class, "CTL_Properties_Action_OK")); // NOI18N
    okButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MercurialOptionsPanelController.class, "CTL_Properties_Action_OK")); // NOI18N
    final JButton cancelButton =  new JButton(NbBundle.getMessage(MercurialOptionsPanelController.class, "CTL_Properties_Action_Cancel")); // NOI18N
    cancelButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MercurialOptionsPanelController.class, "CTL_Properties_Action_Cancel")); // NOI18N
    DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(MercurialOptionsPanelController.class, "CTL_PropertiesDialog_Title", null), // NOI18N
            true, new Object[] {okButton, cancelButton}, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(MercurialOptionsPanelController.class),
            null);
    
    panel.putClientProperty("contentTitle", null);  // NOI18N
    panel.putClientProperty("DialogDescriptor", dd); // NOI18N
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(MercurialOptionsPanelController.class, "CTL_PropertiesDialog_Title")); // NOI18N

    dialog.pack();
    dialog.setVisible(true);
    if (dd.getValue() == okButton) {
        hgProperties.setProperties();
    }
}
 
源代码15 项目: visualvm   文件: OQLQueryCustomizer.java
public static boolean saveQuery(final String query,
                                final OQLSupport.OQLTreeModel treeModel,
                                final JTree tree) {
    JButton okButton = new JButton();
    Mnemonics.setLocalizedText(okButton, Bundle.OQLQueryCustomizer_OkButtonText());

    CustomizerPanel customizer = new CustomizerPanel(okButton,  treeModel);
    final DialogDescriptor dd = new DialogDescriptor(customizer,
                                        Bundle.OQLQueryCustomizer_SaveQueryCaption(), true,
                                        new Object[] { okButton,
                                        DialogDescriptor.CANCEL_OPTION },
                                        okButton, 0, HELP_CTX_SAVE_QUERY, null);
    final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);

    if (dd.getValue() == okButton) {
        OQLSupport.OQLQueryNode node;
        if (customizer.isNewQuery()) {
            OQLSupport.Query q = new OQLSupport.Query(query,
                                    customizer.getQueryName(),
                                    customizer.getQueryDescription());
            node = new OQLSupport.OQLQueryNode(q);
            treeModel.customCategory().add(node);
            treeModel.nodeStructureChanged(treeModel.customCategory());
        } else {
            node = (OQLSupport.OQLQueryNode)customizer.getSelectedValue();
            node.getUserObject().setScript(query);
            treeModel.nodeChanged(node);
        }
        tree.setSelectionPath(new TreePath(treeModel.getPathToRoot(node)));
        return true;
    } else {
        return false;
    }
}
 
源代码16 项目: visualvm   文件: RenameConfigurator.java
public static RenameConfigurator defineName(DataSource dataSource) {
  RenameConfigurator hc = getDefault();
  hc.setupDefineName(dataSource);
  
  final DialogDescriptor dd = new DialogDescriptor(hc, NbBundle.getMessage(RenameConfigurator.class, "LBL_Rename"), true, new Object[] {  // NOI18N
    hc.okButton, DialogDescriptor.CANCEL_OPTION }, hc.okButton, 0, null, null);
  final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
  d.pack();
  d.setVisible(true);
  
  if (dd.getValue() == hc.okButton) return hc;
  else return null;
}
 
源代码17 项目: visualvm   文件: ApplicationSnapshotConfigurator.java
static ApplicationSnapshotConfigurator defineSnapshot() {
  ApplicationSnapshotConfigurator hc = getDefault();
  hc.setupDefineCoreDump();
  
  final DialogDescriptor dd = new DialogDescriptor(hc, NbBundle.getMessage(ApplicationSnapshotConfigurator.class, "Title_Add_Application_Snapshot"), true, new Object[] {   // NOI18N
    hc.okButton, DialogDescriptor.CANCEL_OPTION }, hc.okButton, 0, null, null);
  final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
  d.pack();
  d.setVisible(true);
  
  if (dd.getValue() == hc.okButton) return hc;
  else return null;
}
 
源代码18 项目: netbeans   文件: TaskPanel.java
@NbBundle.Messages({
    "CTL_SelectSubtask_ok=&Add Task",
    "LBL_SelectSubtask_title=Select Task",
    "MSG_SelectSubtask.error.alreadyreferenced=Selected task already referenced.",
    "MSG_SelectSubtask.error.sametask=Cannot reference to the same task."
})
private void btnAddTaskReferenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddTaskReferenceActionPerformed
    referencesSection.setExpanded(true);
    final JButton okButton = new JButton();
    Mnemonics.setLocalizedText(okButton, Bundle.CTL_SelectSubtask_ok());
    okButton.setEnabled(false);
    final AddSubtaskPanel panel = new AddSubtaskPanel();
    panel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged (ChangeEvent e) {
            boolean enabled = panel.getIssue() != null;
            panel.errorLabel.setVisible(false);
            if (enabled) {
                String repoId = panel.getIssue().getRepository().getId();
                String taskId = panel.getIssue().getID();
                if (repoId.equals(LocalRepository.getInstance().getRepository().getId())
                        && taskId.equals(task.getID())) {
                    panel.errorLabel.setText(Bundle.MSG_SelectSubtask_error_sametask());
                    panel.errorLabel.setVisible(true);
                    enabled = false;
                } else {
                    for (TaskReference ref : task.getTaskReferences()) {
                        if (repoId.equals(ref.getRepositoryId()) && taskId.equals(ref.getTaskId())) {
                            panel.errorLabel.setText(Bundle.MSG_SelectSubtask_error_alreadyreferenced());
                            panel.errorLabel.setVisible(true);
                            enabled = false;
                        }
                    }
                }
            }
            okButton.setEnabled(enabled);
        }
    });
    DialogDescriptor dd = new DialogDescriptor(panel, Bundle.LBL_SelectSubtask_title(), true,
            new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN,
            null, null);
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
    dlg.pack();
    panel.errorLabel.setVisible(false);
    dlg.setVisible(true);
    Issue issue = panel.getIssue();
    if (dd.getValue() == okButton && issue != null) {
        unsavedFields.add(ATTRIBUTE_SUBTASKS);
        updateFieldDecorations(ATTRIBUTE_SUBTASKS, referencesSection.getLabelComponent());
        task.addTaskReference(issue);
        refreshViewData();
    }
}
 
源代码19 项目: netbeans   文件: PropertiesAction.java
@Override
protected void performContextAction(Node[] nodes) {
    VCSContext context = HgUtils.getCurrentContext(nodes);
    final File roots[] = HgUtils.getActionRoots(context);
    if (roots == null || roots.length == 0) return;
    final File root = Mercurial.getInstance().getRepositoryRoot(roots[0]);

    final PropertiesPanel panel = new PropertiesPanel();

    final PropertiesTable propTable;

    propTable = new PropertiesTable(panel.labelForTable, PropertiesTable.PROPERTIES_COLUMNS);

    panel.setPropertiesTable(propTable);

    JComponent component = propTable.getComponent();

    panel.propsPanel.setLayout(new BorderLayout());

    panel.propsPanel.add(component, BorderLayout.CENTER);

    HgProperties hgProperties = new HgProperties(panel, propTable, root);        

    DialogDescriptor dd = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(PropertiesAction.class, "CTL_PropertiesDialog_Title", null), true, null); // NOI18N
    JButton okButton =  new JButton();
    org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(PropertiesAction.class, "CTL_Properties_Action_OK"));
    okButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSN_Properties_Action_OK")); // NOI18N
    okButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSD_Properties_Action_OK")); 
    JButton cancelButton =  new JButton();
    org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(PropertiesAction.class, "CTL_Properties_Action_Cancel"));
    cancelButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSN_Properties_Action_Cancel")); // NOI18N
    cancelButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSD_Properties_Action_Cancel")); 
    dd.setOptions(new Object[] {okButton, cancelButton});
    dd.setHelpCtx(new HelpCtx(PropertiesAction.class));
    panel.putClientProperty("contentTitle", null);  // NOI18N
    panel.putClientProperty("DialogDescriptor", dd); // NOI18N
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PropertiesAction.class, "ACSD_Properties_Dialog")); // NOI18N
    dialog.pack();
    dialog.setVisible(true);
    if (dd.getValue() == okButton) {
        hgProperties.updateLastSelection();
        hgProperties.setProperties();
    }
}
 
源代码20 项目: openjdk-jdk9   文件: ChangeWindowResizabiltyTest.java
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();
    }
}