@Test public void testGetJDialogInstance() { System.out.println("getJDialogInstance"); Frame owner = null; String title = "test"; boolean modal = false; JAbsrtactDialogPanel content = new JAbsrtactDialogPanelImpl(); JDialog result = DialogFactory.getJDialogInstance(owner, title, modal, content, "/kg/apc/jmeter/vizualizers/wand.png"); assertEquals(result == null, GraphicsEnvironment.isHeadless()); }
public static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath) { if(!GraphicsEnvironment.isHeadless()) { JDialog ret = new JDialog(owner, title, modal); ret.add(content); ret.pack(); Dimension size = ret.getPreferredSize(); if(size.width < content.getMinWidth()) { size.width = content.getMinWidth(); } ret.setSize(size); ret.validate(); if(imagePath != null) { ImageIcon imageIcon = new ImageIcon(DialogFactory.class.getResource(imagePath)); if(imageIcon != null) { ret.setIconImage(imageIcon.getImage()); } } return ret; } else { return null; } }
DialogFactory { public static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath) { if(!GraphicsEnvironment.isHeadless()) { JDialog ret = new JDialog(owner, title, modal); ret.add(content); ret.pack(); Dimension size = ret.getPreferredSize(); if(size.width < content.getMinWidth()) { size.width = content.getMinWidth(); } ret.setSize(size); ret.validate(); if(imagePath != null) { ImageIcon imageIcon = new ImageIcon(DialogFactory.class.getResource(imagePath)); if(imageIcon != null) { ret.setIconImage(imageIcon.getImage()); } } return ret; } else { return null; } } }
DialogFactory { public static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath) { if(!GraphicsEnvironment.isHeadless()) { JDialog ret = new JDialog(owner, title, modal); ret.add(content); ret.pack(); Dimension size = ret.getPreferredSize(); if(size.width < content.getMinWidth()) { size.width = content.getMinWidth(); } ret.setSize(size); ret.validate(); if(imagePath != null) { ImageIcon imageIcon = new ImageIcon(DialogFactory.class.getResource(imagePath)); if(imageIcon != null) { ret.setIconImage(imageIcon.getImage()); } } return ret; } else { return null; } }  }
DialogFactory { public static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath) { if(!GraphicsEnvironment.isHeadless()) { JDialog ret = new JDialog(owner, title, modal); ret.add(content); ret.pack(); Dimension size = ret.getPreferredSize(); if(size.width < content.getMinWidth()) { size.width = content.getMinWidth(); } ret.setSize(size); ret.validate(); if(imagePath != null) { ImageIcon imageIcon = new ImageIcon(DialogFactory.class.getResource(imagePath)); if(imageIcon != null) { ret.setIconImage(imageIcon.getImage()); } } return ret; } else { return null; } }  static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath); static void centerDialog(Frame parent, JDialog dialog); }
DialogFactory { public static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath) { if(!GraphicsEnvironment.isHeadless()) { JDialog ret = new JDialog(owner, title, modal); ret.add(content); ret.pack(); Dimension size = ret.getPreferredSize(); if(size.width < content.getMinWidth()) { size.width = content.getMinWidth(); } ret.setSize(size); ret.validate(); if(imagePath != null) { ImageIcon imageIcon = new ImageIcon(DialogFactory.class.getResource(imagePath)); if(imageIcon != null) { ret.setIconImage(imageIcon.getImage()); } } return ret; } else { return null; } }  static JDialog getJDialogInstance(Frame owner, String title, boolean modal, JAbsrtactDialogPanel content, String imagePath); static void centerDialog(Frame parent, JDialog dialog);  }