/* * Jeti, a Java Jabber client, Copyright (C) 2001 E.S. de Boer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * For questions, comments etc, * use the website at http://jeti.jabberstudio.org * or mail/IM me at jeti@jabber.org */ package nu.fw.jeti.util; import java.awt.Container; import java.awt.HeadlessException; import javax.swing.Icon; import javax.swing.JOptionPane; /** * This class wraps Joptionpane to provide non blocking popups * @author E.S. de Boer */ public class Popups { static private Container main; public Popups(Container window) { main = window; } public static void errorPopup(String error,String title) { popup(error,title,JOptionPane.ERROR_MESSAGE); //JOptionPane.showMessageDialog(main,error,title,JOptionPane.ERROR_MESSAGE); } public static void criticalErrorPopup(String error,String title) { //popup(error,title,javax.swing.JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(main,error,title,JOptionPane.ERROR_MESSAGE); } public static void messagePopup(String message,String title) { popup(message,title,JOptionPane.INFORMATION_MESSAGE); //JOptionPane.showMessageDialog(main,error,title,JOptionPane.ERROR_MESSAGE); } public static void popup(String text,String title,int message) { if(main!=null)main.show();// toFront(); showMessageDialog(text,title,message); } public static void showOptionDialog(Object message, String title, int optionType, int messageType, Icon icon,final Object[] options, Object initialValue,OptionChoosed choosed) { if(main!=null)main.show(); JOptionPaneNonModal.showOptionDialog( main,message,title,optionType,messageType,icon,options,initialValue ,choosed); } /* static class TempThread extends Thread { private String title; private String text; private int message; public TempThread(String text, String title,int message) { this.text =text; this.title =title; this.message =message; } public void run() { popup(text,title,message); } } */ /** * Brings up a dialog that displays a message using a default * icon determined by the messageType parameter. * * @param parentComponent determines the Frame * in which the dialog is displayed; if null, * or if the parentComponent has no * Frame, a default Frame is used * @param message the Object to display * @param title the title string for the dialog * @param messageType the type of message to be displayed: * ERROR_MESSAGE, * INFORMATION_MESSAGE, * WARNING_MESSAGE, * QUESTION_MESSAGE, * or PLAIN_MESSAGE * @exception HeadlessException if * GraphicsEnvironment.isHeadless returns * true * @see java.awt.GraphicsEnvironment#isHeadless */ public static void showMessageDialog(Object message, String title, int messageType) { showMessageDialog(message, title, messageType, null); } /** * Brings up a dialog displaying a message, specifying all parameters. * * @param parentComponent determines the Frame in which the * dialog is displayed; if null, * or if the parentComponent has no * Frame, a * default Frame is used * @param message the Object to display * @param title the title string for the dialog * @param messageType the type of message to be displayed: * ERROR_MESSAGE, * INFORMATION_MESSAGE, * WARNING_MESSAGE, * QUESTION_MESSAGE, * or PLAIN_MESSAGE * @param icon an icon to display in the dialog that helps the user * identify the kind of message that is being displayed * @exception HeadlessException if * GraphicsEnvironment.isHeadless returns * true * @see java.awt.GraphicsEnvironment#isHeadless */ public static void showMessageDialog( Object message, String title, int messageType, Icon icon) { showOptionDialog(message, title, JOptionPane.DEFAULT_OPTION, messageType, icon, null, null,null); } public interface OptionChoosed { void optionChoosed(int option); } } /* * Overrides for emacs * Local variables: * tab-width: 4 * End: */