/** * SlingBeans - NetBeans Sling plugin https://github.com/jkan997/SlingBeans * Licensed under Apache 2.0 license http://www.apache.org/licenses/LICENSE-2.0 */ package org.jkan997.slingbeans.helper; import java.awt.Dimension; import java.awt.Toolkit; import javax.swing.JDialog; import javax.swing.JOptionPane; /** * * @author jkan997 */ public class SwingHelper { public static void showDialog(JDialog d) { final Toolkit toolkit = Toolkit.getDefaultToolkit(); final Dimension screenSize = toolkit.getScreenSize(); final int x = (screenSize.width - d.getWidth()) / 2; final int y = (screenSize.height - d.getHeight()) / 2; d.setLocation(x, y); d.setVisible(true); } public static void showMessage(String msg) { JOptionPane.showMessageDialog(null, msg, "Information", JOptionPane.INFORMATION_MESSAGE); } public static boolean showConfirmation(String msg) { int res = JOptionPane.showConfirmDialog(null, msg, "Confirmation", JOptionPane.YES_NO_OPTION); return (res==0); } }