/** * Show a dialog with the proved message. * @param message */ public static void showDialog(String message){ ErrorDialog dialog = new ErrorDialog(message); dialog.setVisible(true); } }
/** * Create a new Dialog with a title and a message. * @param message * @param title */ public ErrorDialog(String message, String title) { setTitle(title); setSize(new Dimension(600, 400)); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setLocationRelativeTo(null); Container container = getContentPane(); container.setLayout(new BorderLayout()); JTextArea textArea = new JTextArea(); textArea.setText(message); textArea.setEditable(false); textArea.setMargin(new Insets(PADDING, PADDING, PADDING, PADDING)); add(new JScrollPane(textArea), BorderLayout.CENTER); final JDialog dialog = this; JButton button = new JButton(new AbstractAction("OK"){ @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); add(button, BorderLayout.SOUTH); }
public void run() { ErrorDialog.showDialog(msg); } });
/** * Create a new Dialog with a title and a message. * @param message * @param title */ public ErrorDialog(String message, String title) { setTitle(title); setSize(new Dimension(600, 400)); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setLocationRelativeTo(null); Container container = getContentPane(); container.setLayout(new BorderLayout()); JTextArea textArea = new JTextArea(); textArea.setText(message); textArea.setEditable(false); textArea.setMargin(new Insets(PADDING, PADDING, PADDING, PADDING)); add(new JScrollPane(textArea), BorderLayout.CENTER); final JDialog dialog = this; JButton button = new JButton(new AbstractAction("OK"){ @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); add(button, BorderLayout.SOUTH); }
/** * Show a dialog with the proved message. * @param message */ public static void showDialog(String message){ ErrorDialog dialog = new ErrorDialog(message); dialog.setVisible(true); } }
public void run() { ErrorDialog.showDialog(msg); } });