Java Code Examples for java.awt.Dialog#pack()
The following examples show how to use
java.awt.Dialog#pack() .
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: AttachDialog.java From visualvm with GNU General Public License v2.0 | 6 votes |
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); }
Example 2
Source File: AttachDialog.java From netbeans with Apache License 2.0 | 6 votes |
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); }
Example 3
Source File: PropertiesConfigurator.java From visualvm with GNU General Public License v2.0 | 6 votes |
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(); }
Example 4
Source File: MissingDatabaseConnectionWarning.java From netbeans with Apache License 2.0 | 6 votes |
/** * 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(); } } }
Example 5
Source File: RevisionPicker.java From netbeans with Apache License 2.0 | 6 votes |
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; }
Example 6
Source File: ValuesCustomizer.java From visualvm with GNU General Public License v2.0 | 6 votes |
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; }
Example 7
Source File: SvnPropertiesAction.java From netbeans with Apache License 2.0 | 5 votes |
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); }
Example 8
Source File: ApplicationSnapshotConfigurator.java From visualvm with GNU General Public License v2.0 | 5 votes |
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; }
Example 9
Source File: RenameConfigurator.java From visualvm with GNU General Public License v2.0 | 5 votes |
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; }
Example 10
Source File: OQLQueryCustomizer.java From visualvm with GNU General Public License v2.0 | 5 votes |
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; } }
Example 11
Source File: MercurialOptionsPanelController.java From netbeans with Apache License 2.0 | 5 votes |
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(); } }
Example 12
Source File: ObjectDisplayOpacityPanel.java From opensim-gui with Apache License 2.0 | 5 votes |
void showDialog() { DialogDescriptor dlg = new DialogDescriptor(this, "Select Opacity"); dlg.setOptions(new Object[]{}); Dialog dialog = DialogDisplayer.getDefault().createDialog(dlg); dialog.pack(); dialog.setVisible(true); }
Example 13
Source File: NoSelectedServerWarning.java From netbeans with Apache License 2.0 | 5 votes |
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; }
Example 14
Source File: DialogUtils.java From opensim-gui with Apache License 2.0 | 5 votes |
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(); }
Example 15
Source File: HostCustomizer.java From visualvm with GNU General Public License v2.0 | 5 votes |
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; } }
Example 16
Source File: ProfilingPointsDisplayer.java From netbeans with Apache License 2.0 | 5 votes |
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(); }
Example 17
Source File: AnalysisControllerUI.java From visualvm with GNU General Public License v2.0 | 5 votes |
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); }
Example 18
Source File: TaskPanel.java From netbeans with Apache License 2.0 | 4 votes |
@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(); } }
Example 19
Source File: PropertiesAction.java From netbeans with Apache License 2.0 | 4 votes |
@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(); } }
Example 20
Source File: ChangeWindowResizabiltyTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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(); } }