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

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

源代码1 项目: ccu-historian   文件: RefineryUtilities.java
/**
 * Positions the specified dialog at a position relative to its parent.
 *
 * @param dialog  the dialog to be positioned.
 * @param horizontalPercent  the relative location.
 * @param verticalPercent  the relative location.
 */
public static void positionDialogRelativeToParent(final Dialog dialog,
                                                  final double horizontalPercent,
                                                  final double verticalPercent) {
  final Container parent = dialog.getParent();
  if (parent == null)
  {
    centerFrameOnScreen(dialog);
    return;
  }

  final Dimension d = dialog.getSize();
  final Dimension p = parent.getSize();

  final int baseX = parent.getX();
  final int baseY = parent.getY();

  final int x = baseX + (int) (horizontalPercent * p.width);
  final int y = baseY + (int) (verticalPercent * p.height);

  // make sure the dialog fits completely on the screen...
  final Rectangle s = parent.getGraphicsConfiguration().getBounds();
  final Rectangle r = new Rectangle(x, y, d.width, d.height);
  dialog.setBounds(r.intersection(s));
}
 
源代码2 项目: astor   文件: RefineryUtilities.java
/**
 * Positions the specified dialog at a position relative to its parent.
 *
 * @param dialog  the dialog to be positioned.
 * @param horizontalPercent  the relative location.
 * @param verticalPercent  the relative location.
 */
public static void positionDialogRelativeToParent(Dialog dialog,
                                                  double horizontalPercent,
                                                  double verticalPercent) {
    Dimension d = dialog.getSize();
    Container parent = dialog.getParent();
    Dimension p = parent.getSize();

    int baseX = parent.getX() - d.width;
    int baseY = parent.getY() - d.height;
    int w = d.width + p.width;
    int h = d.height + p.height;
    int x = baseX + (int) (horizontalPercent * w);
    int y = baseY + (int) (verticalPercent * h);

    // make sure the dialog fits completely on the screen...
    Rectangle s = getMaximumWindowBounds();
    x = Math.min(x, (s.width - d.width));
    x = Math.max(x, 0);
    y = Math.min(y, (s.height - d.height));
    y = Math.max(y, 0);

    dialog.setBounds(x + s.x, y + s.y, d.width, d.height);

}
 
源代码3 项目: openjdk-jdk9   文件: InvisibleParentTest.java
private void createAWTComponents() {
    Frame f1 = new Frame("F1");
    f1.setBounds(100, 300, 100, 100);
    f1.setVisible(true);

    try {
        Thread.sleep(500);
    } catch (Exception ex) {
    }

    f1.setExtendedState(Frame.ICONIFIED);

    Frame g1 = new Frame("G1");
    g1.setBounds(150, 350, 100, 100);
    g1.setVisible(true);

    final Dialog d1 = new Dialog((Frame) null, "D1", Dialog.ModalityType.APPLICATION_MODAL);
    d1.setBounds(200, 400, 100, 100);
    new Thread(new Runnable() {
        public void run() {
            d1.setVisible(true);
        }
    }).start();
}
 
源代码4 项目: astor   文件: RefineryUtilities.java
/**
 * Positions the specified dialog at a position relative to its parent.
 *
 * @param dialog  the dialog to be positioned.
 * @param horizontalPercent  the relative location.
 * @param verticalPercent  the relative location.
 */
public static void positionDialogRelativeToParent(Dialog dialog,
                                                  double horizontalPercent,
                                                  double verticalPercent) {
    Dimension d = dialog.getSize();
    Container parent = dialog.getParent();
    Dimension p = parent.getSize();

    int baseX = parent.getX() - d.width;
    int baseY = parent.getY() - d.height;
    int w = d.width + p.width;
    int h = d.height + p.height;
    int x = baseX + (int) (horizontalPercent * w);
    int y = baseY + (int) (verticalPercent * h);

    // make sure the dialog fits completely on the screen...
    Rectangle s = getMaximumWindowBounds();
    x = Math.min(x, (s.width - d.width));
    x = Math.max(x, 0);
    y = Math.min(y, (s.height - d.height));
    y = Math.max(y, 0);

    dialog.setBounds(x + s.x, y + s.y, d.width, d.height);

}
 
源代码5 项目: dragonwell8_jdk   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
源代码6 项目: dragonwell8_jdk   文件: DialogAboveFrameTest.java
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame frame = new Frame("Frame");
    frame.setBackground(Color.BLUE);
    frame.setBounds(200, 50, 300, 300);
    frame.setVisible(true);

    Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
    dialog1.setBackground(Color.RED);
    dialog1.setBounds(100, 100, 200, 200);
    dialog1.setVisible(true);

    Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
    dialog2.setBackground(Color.GREEN);
    dialog2.setBounds(400, 100, 200, 200);
    dialog2.setVisible(true);

    Util.waitForIdle(robot);

    Util.clickOnComp(dialog2, robot);
    Util.waitForIdle(robot);

    Point point = dialog1.getLocationOnScreen();
    int x = point.x + (int)(dialog1.getWidth() * 0.9);
    int y = point.y + (int)(dialog1.getHeight() * 0.9);

    try {
        if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
            throw new RuntimeException("Test FAILED: Dialog is behind the frame");
        }
    } finally {
        frame.dispose();
        dialog1.dispose();
        dialog2.dispose();
    }
}
 
源代码7 项目: TencentKona-8   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
源代码8 项目: TencentKona-8   文件: DialogAboveFrameTest.java
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame frame = new Frame("Frame");
    frame.setBackground(Color.BLUE);
    frame.setBounds(200, 50, 300, 300);
    frame.setVisible(true);

    Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
    dialog1.setBackground(Color.RED);
    dialog1.setBounds(100, 100, 200, 200);
    dialog1.setVisible(true);

    Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
    dialog2.setBackground(Color.GREEN);
    dialog2.setBounds(400, 100, 200, 200);
    dialog2.setVisible(true);

    Util.waitForIdle(robot);

    Util.clickOnComp(dialog2, robot);
    Util.waitForIdle(robot);

    Point point = dialog1.getLocationOnScreen();
    int x = point.x + (int)(dialog1.getWidth() * 0.9);
    int y = point.y + (int)(dialog1.getHeight() * 0.9);

    try {
        if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
            throw new RuntimeException("Test FAILED: Dialog is behind the frame");
        }
    } finally {
        frame.dispose();
        dialog1.dispose();
        dialog2.dispose();
    }
}
 
源代码9 项目: jdk8u60   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
源代码10 项目: openjdk-jdk8u   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
源代码11 项目: jdk8u_jdk   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
源代码12 项目: hottub   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
源代码13 项目: jdk8u-jdk   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame frame = new Frame("Frame");
    frame.setBackground(Color.BLUE);
    frame.setBounds(200, 50, 300, 300);
    frame.setVisible(true);

    Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
    dialog1.setBackground(Color.RED);
    dialog1.setBounds(100, 100, 200, 200);
    dialog1.setVisible(true);

    Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
    dialog2.setBackground(Color.GREEN);
    dialog2.setBounds(400, 100, 200, 200);
    dialog2.setVisible(true);

    Util.waitForIdle(robot);

    Util.clickOnComp(dialog2, robot);
    Util.waitForIdle(robot);

    Point point = dialog1.getLocationOnScreen();
    int x = point.x + (int)(dialog1.getWidth() * 0.9);
    int y = point.y + (int)(dialog1.getHeight() * 0.9);

    try {
        if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
            throw new RuntimeException("Test FAILED: Dialog is behind the frame");
        }
    } finally {
        frame.dispose();
        dialog1.dispose();
        dialog2.dispose();
    }
}
 
源代码16 项目: openjdk-jdk9   文件: DialogAboveFrameTest.java
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame frame = new Frame("Frame");
    frame.setBackground(Color.BLUE);
    frame.setBounds(200, 50, 300, 300);
    frame.setVisible(true);

    Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
    dialog1.setBackground(Color.RED);
    dialog1.setBounds(100, 100, 200, 200);
    dialog1.setVisible(true);

    Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
    dialog2.setBackground(Color.GREEN);
    dialog2.setBounds(400, 100, 200, 200);
    dialog2.setVisible(true);

    Util.waitForIdle(robot);

    Util.clickOnComp(dialog2, robot);
    Util.waitForIdle(robot);

    Point point = dialog1.getLocationOnScreen();
    int x = point.x + (int)(dialog1.getWidth() * 0.9);
    int y = point.y + (int)(dialog1.getHeight() * 0.9);

    try {
        if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
            throw new RuntimeException("Test FAILED: Dialog is behind the frame");
        }
    } finally {
        frame.dispose();
        dialog1.dispose();
        dialog2.dispose();
    }
}
 
源代码17 项目: jdk8u-jdk   文件: NpeOnCloseTest.java
public static void main(String[] args)
{
    Frame frame1 = new Frame("frame 1");
    frame1.setBounds(0, 0, 100, 100);
    frame1.setVisible(true);
    Util.waitForIdle(null);

    Frame frame2 = new Frame("frame 2");
    frame2.setBounds(150, 0, 100, 100);
    frame2.setVisible(true);
    Util.waitForIdle(null);

    Frame frame3 = new Frame("frame 3");
    final Dialog dialog = new Dialog(frame3, "dialog", true);
    dialog.setBounds(300, 0, 100, 100);
    EventQueue.invokeLater(new Runnable() {
            public void run() {
                dialog.setVisible(true);
            }
        });
    try {
        EventQueue.invokeAndWait(new Runnable() { public void run() {} });
        Util.waitForIdle(null);
        EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    dialog.dispose();
                }
            });
    }
    catch (InterruptedException ie) {
        throw new RuntimeException(ie);
    }
    catch (InvocationTargetException ite) {
        throw new RuntimeException(ite);
    }

    frame1.dispose();
    frame2.dispose();
    frame3.dispose();
}
 
源代码18 项目: jdk8u-jdk   文件: DialogAboveFrameTest.java
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame frame = new Frame("Frame");
    frame.setBackground(Color.BLUE);
    frame.setBounds(200, 50, 300, 300);
    frame.setVisible(true);

    Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
    dialog1.setBackground(Color.RED);
    dialog1.setBounds(100, 100, 200, 200);
    dialog1.setVisible(true);

    Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
    dialog2.setBackground(Color.GREEN);
    dialog2.setBounds(400, 100, 200, 200);
    dialog2.setVisible(true);

    Util.waitForIdle(robot);

    Util.clickOnComp(dialog2, robot);
    Util.waitForIdle(robot);

    Point point = dialog1.getLocationOnScreen();
    int x = point.x + (int)(dialog1.getWidth() * 0.9);
    int y = point.y + (int)(dialog1.getHeight() * 0.9);

    try {
        if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
            throw new RuntimeException("Test FAILED: Dialog is behind the frame");
        }
    } finally {
        frame.dispose();
        dialog1.dispose();
        dialog2.dispose();
    }
}
 
源代码19 项目: netbeans   文件: NbPresenterLeakTest.java
@RandomlyFails // NB-Core-Build #1189
public void testLeakingNbPresenterDescriptor () throws InterruptedException, InvocationTargetException {
    try {
        Class.forName("java.lang.AutoCloseable");
    } catch (ClassNotFoundException ex) {
        // this test is known to fail due to JDK bugs 7070542 & 7072167
        // which are unlikely to be fixed on JDK6. Thus, if AutoCloseable
        // is not present, skip the test
        return;
    }
    
    WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels(), null);
    wizardDescriptor.setModal (false);
    Dialog dialog = DialogDisplayer.getDefault ().createDialog (wizardDescriptor);
    WeakReference<WizardDescriptor> w = new WeakReference<WizardDescriptor> (wizardDescriptor);
    
    SwingUtilities.invokeAndWait (new EDTJob(dialog, true));
    assertShowing("button is visible", true, dialog);
    SwingUtilities.invokeAndWait (new EDTJob(dialog, false));
    assertShowing("button is no longer visible", false, dialog);
    boolean cancelled = wizardDescriptor.getValue() !=
        WizardDescriptor.FINISH_OPTION;
    Dialog d = new JDialog();
    
    // workaround for JDK bug 6575402
    JPanel p = new JPanel();
    d.setLayout(new BorderLayout());
    d.add(p, BorderLayout.CENTER);
    JButton btn = new JButton("Button");
    p.add(btn, BorderLayout.NORTH);
    
    SwingUtilities.invokeAndWait (new EDTJob(d, true));
    assertShowing("button is visible", true, btn);
    dialog.setBounds(Utilities.findCenterBounds(dialog.getSize()));
    SwingUtilities.invokeAndWait (new EDTJob(d, false));
    assertShowing("button is no longer visible", false, btn);

    assertNull ("BufferStrategy was disposed.", dialog.getBufferStrategy ());

    RepaintManager rm = RepaintManager.currentManager(dialog);
    rm.setDoubleBufferingEnabled(!rm.isDoubleBufferingEnabled());
    rm.setDoubleBufferingEnabled(!rm.isDoubleBufferingEnabled());
    
    dialog = null;
    wizardDescriptor = null;
    
    SwingUtilities.invokeAndWait (new Runnable() {

        @Override
        public void run() {
            Frame f = new Frame();
            f.setPreferredSize( new Dimension(100,100));
            f.setVisible( true );
            JDialog dlg = new JDialog(f);
            dlg.setVisible(true);
        }
    });

    assertGC ("Dialog disappears.", w);
}
 
源代码20 项目: netbeans   文件: FileSearchAction.java
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;
}