Java Code Examples for javax.swing.JDialog#setBounds()
The following examples show how to use
javax.swing.JDialog#setBounds() .
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: ProgressUI.java From netbeans with Apache License 2.0 | 6 votes |
/** Display the modal progress dialog. This method should be called from the AWT Event Dispatch thread. */ public void showProgressDialog() { if (finished) { return; // do not display the dialog if we are done } dialog = new JDialog(WindowManager.getDefault().getMainWindow(), title, true); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); String lastMessageTmp; synchronized (this) { lastMessageTmp = lastMessage; } dialog.getContentPane().add(createProgressDialog( handle, lastMessageTmp != null ? lastMessageTmp : title)); dialog.pack(); dialog.setBounds(Utilities.findCenterBounds(dialog.getSize())); dialog.setLocationRelativeTo(WindowManager.getDefault().getMainWindow()); dialog.setVisible(true); }
Example 2
Source File: ResizablePopup.java From netbeans with Apache License 2.0 | 6 votes |
public static JDialog getDialog() { JDialog dialog = new JDialog(WindowManager.getDefault().getMainWindow(), "", false) { private static final long serialVersionUID = -2488334519927160789L; public void setVisible(boolean visible) { boolean wasVisible = isVisible(); if (wasVisible && !visible) { WebBeansNavigationOptions.setLastBounds(getBounds()); } super.setVisible(visible); } }; //dialog.setUndecorated(true); dialog.setBounds(WebBeansNavigationOptions.getLastBounds()); dialog.addWindowListener(windowListener); dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); return dialog; }
Example 3
Source File: ExtTestCase.java From netbeans with Apache License 2.0 | 5 votes |
private static void showDialog(JFrame parent) throws Exception { jd = new JDialog(parent); jtf = new JTextField("What a day I'm having!"); jd.getContentPane().setLayout(new BorderLayout()); jd.getContentPane().add(jtf, BorderLayout.CENTER); jd.setBounds(400,400,100, 50); new WaitWindow(jd); sleep(); }
Example 4
Source File: Utils.java From netbeans with Apache License 2.0 | 5 votes |
@Override public State mouseClicked(Widget widget, WidgetMouseEvent event) { if (event.getButton() == MouseEvent.BUTTON1) { JDialog dialog = new JDialog((Frame) null, "Mouse Clicked " + event.getClickCount()); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setBounds((screenSize.width - WIDTH) / 2, (screenSize.height - HEIGHT) / 2, WIDTH, HEIGHT); dialog.setVisible(true); return State.CONSUMED; } return State.REJECTED; }
Example 5
Source File: CampaignEditor.java From open-ig with GNU Lesser General Public License v3.0 | 5 votes |
/** * Load the window state from the specified XML element. * @param w the target frame * @param xml the xml element */ public static void loadWindowState(JDialog w, XElement xml) { if (xml == null) { return; } int x = xml.getInt("window-x", w.getX()); int y = xml.getInt("window-y", w.getY()); int width = xml.getInt("window-width", w.getWidth()); int height = xml.getInt("window-height", w.getHeight()); w.setBounds(x, y, width, height); }
Example 6
Source File: ChatTranscriptPlugin.java From Spark with Apache License 2.0 | 5 votes |
private void showStatusMessage(ContactItem item) { Frame = new JDialog(); Frame.setTitle(item.getDisplayName() + " - Status"); JPanel pane = new JPanel(); JTextArea textArea = new JTextArea(5, 30); JButton btn_close = new JButton(Res.getString("button.close")); btn_close.addActionListener( e -> Frame.setVisible(false) ); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); pane.add(new JScrollPane(textArea)); Frame.setLayout(new BorderLayout()); Frame.add(pane, BorderLayout.CENTER); Frame.add(btn_close, BorderLayout.SOUTH); textArea.setEditable(false); textArea.setText(item.getStatus()); Frame.setLocationRelativeTo(SparkManager.getMainWindow()); Frame.setBounds(Frame.getX() - 175, Frame.getY() - 75, 350, 150); Frame.setSize(350, 150); Frame.setResizable(false); Frame.setVisible(true); }
Example 7
Source File: PluginManagerActionTest.java From netbeans with Apache License 2.0 | 4 votes |
public void testMemLeakPluginManagerUI () throws Exception { help = this; close = new JButton (); SwingUtilities.invokeAndWait (new Runnable () { public void run () { ui = new PluginManagerUI (close); } }); assertNotNull (ui); ref = new WeakReference<PluginManagerUI> (ui); assertNotNull (ref.get ()); dlg = new JDialog (new JFrame ()); dlg.setBounds (100, 100, 800, 500); dlg.add (ui); SwingUtilities.invokeAndWait (new Runnable () { public void run () { dlg.setVisible (true); } }); ui.initTask.waitFinished (); Thread.sleep (1000); SwingUtilities.invokeAndWait (new Runnable () { public void run () { dlg.setVisible (false); dlg.getContentPane ().removeAll (); dlg.dispose (); } }); Thread.sleep (10500); //dlg = null; close = null; ui = null; assertNull (ui); ToolTipManager.sharedInstance ().mousePressed (null); // sun.management.ManagementFactoryHelper.getDiagnosticMXBean().dumpHeap("/tmp/heapdump2.out", true); assertGC ("Reference to PluginManagerUI is empty.", ref); assertNotNull (ref); assertNull (ref.get ()); }
Example 8
Source File: CustomizerDialog.java From netbeans with Apache License 2.0 | 4 votes |
public void actionPerformed( final ActionEvent e ) { String command = e.getActionCommand(); if ( COMMAND_OK.equals( command ) ) { // Call the OK option listener ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() { public Object run() { okOptionListener.actionPerformed( e ); // XXX maybe create new event actionPerformed(e, categories); return null; } }); final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data_progress")); JComponent component = ProgressHandleFactory.createProgressComponent(handle); Frame mainWindow = WindowManager.getDefault().getMainWindow(); final JDialog dialog = new JDialog(mainWindow, NbBundle.getMessage(CustomizerDialog.class, "LBL_Saving_Project_data"), true); SavingProjectDataPanel panel = new SavingProjectDataPanel(component); dialog.getContentPane().add(panel); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); dialog.pack(); Rectangle bounds = mainWindow.getBounds(); int middleX = bounds.x + bounds.width / 2; int middleY = bounds.y + bounds.height / 2; Dimension size = dialog.getPreferredSize(); dialog.setBounds(middleX - size.width / 2, middleY - size.height / 2, size.width, size.height); // Call storeListeners out of AWT EQ RequestProcessor.getDefault().post(new Runnable() { @Override public void run() { try { ProjectManager.mutex().writeAccess(new Mutex.Action<Object>() { @Override public Object run() { FileUtil.runAtomicAction(new Runnable() { @Override public void run() { handle.start(); if (storeListener != null) { storeListener.actionPerformed(e); } storePerformed(e, categories); // #97998 related saveModifiedProject(); } }); return null; } }); } finally { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { dialog.setVisible(false); dialog.dispose(); } }); } } }); dialog.setVisible(true); } }
Example 9
Source File: SwingHelper.java From libGDX-Path-Editor with Apache License 2.0 | 4 votes |
public static void setDialogWindowToCenter(JDialog dialog){ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setBounds((screenSize.width-dialog.getWidth())/2, (screenSize.height-dialog.getHeight())/2, dialog.getWidth(), dialog.getHeight()); }