Java Code Examples for java.awt.Dialog#setPreferredSize()
The following examples show how to use
java.awt.Dialog#setPreferredSize() .
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: TableViewTopComponent.java From constellation with Apache License 2.0 | 6 votes |
private void createSelectColumnDialog() { final ColumnSelectPanel panel = new ColumnSelectPanel(dataTable); final JButton cancelButton = new JButton("Cancel"); final JButton okButton = new JButton("OK"); final DialogDescriptor dd = new DialogDescriptor(panel, "Select Column...", true, new Object[]{ okButton, cancelButton }, "OK", DialogDescriptor.DEFAULT_ALIGN, null, (final ActionEvent e) -> { if (e.getActionCommand().equals("OK")) { try { panel.okButtonActionPerformed(e); } catch (Exception ex) { Exceptions.printStackTrace(ex); } } }); dd.setClosingOptions(new JButton[]{ cancelButton, okButton }); Dialog d; d = DialogDisplayer.getDefault().createDialog(dd); d.pack(); d.setPreferredSize(new Dimension(200, 350)); d.setMinimumSize(new Dimension(350, 450)); d.setVisible(true); }
Example 2
Source File: MethodExceptionDialog.java From netbeans with Apache License 2.0 | 6 votes |
public void showDialog(JComponent invoker) { DialogDescriptor dlg = new DialogDescriptor( this, NbBundle.getMessage(this.getClass(), "CLIENT_EXCEPTION"), // NOI18N false, NotifyDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, null); dlg.setOptions(new Object[] { okButton }); Dialog dialog = DialogDisplayer.getDefault().createDialog(dlg); dialog.setPreferredSize(new Dimension(500,300)); dialog.setLocationRelativeTo(invoker); dialog.setVisible(true); }
Example 3
Source File: DialogFactory.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 4
Source File: FileSearchAction.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 5
Source File: GoToTypeAction.java From netbeans with Apache License 2.0 | 4 votes |
/** 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; }