@Test public void testCenterDialog() { System.out.println("centerDialog"); Frame parent = null; JDialog dialog = null; if(!GraphicsEnvironment.isHeadless()) { parent = new JFrame("Frame"); parent.setBounds(10, 10, 640, 480); dialog = new JDialog(parent, "Dialog"); dialog.setSize(200, 50); } DialogFactory.centerDialog(parent, dialog); }
public static void centerDialog(Frame parent, JDialog dialog) { if(parent != null && dialog != null) { dialog.setLocation(parent.getLocation().x + (parent.getSize().width - dialog.getSize().width) / 2, parent.getLocation().y + (parent.getSize().height - dialog.getSize().height) / 2); } }
DialogFactory { public static void centerDialog(Frame parent, JDialog dialog) { if(parent != null && dialog != null) { dialog.setLocation(parent.getLocation().x + (parent.getSize().width - dialog.getSize().width) / 2, parent.getLocation().y + (parent.getSize().height - dialog.getSize().height) / 2); } } }
DialogFactory { public static void centerDialog(Frame parent, JDialog dialog) { if(parent != null && dialog != null) { dialog.setLocation(parent.getLocation().x + (parent.getSize().width - dialog.getSize().width) / 2, parent.getLocation().y + (parent.getSize().height - dialog.getSize().height) / 2); } }  }
DialogFactory { public static void centerDialog(Frame parent, JDialog dialog) { if(parent != null && dialog != null) { dialog.setLocation(parent.getLocation().x + (parent.getSize().width - dialog.getSize().width) / 2, parent.getLocation().y + (parent.getSize().height - dialog.getSize().height) / 2); } }  static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath); static void centerDialog(Frame parent, JDialog dialog); }
DialogFactory { public static void centerDialog(Frame parent, JDialog dialog) { if(parent != null && dialog != null) { dialog.setLocation(parent.getLocation().x + (parent.getSize().width - dialog.getSize().width) / 2, parent.getLocation().y + (parent.getSize().height - dialog.getSize().height) / 2); } }  static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath); static void centerDialog(Frame parent, JDialog dialog);  }