source: 3thparty/jmessenger/src/nu/fw/jeti/util/Popups.java @ 3952

Revision 3952, 5.1 KB checked in by alexandrecorreia, 13 years ago (diff)

Ticket #1710 - Adicao do codigo fonte java do componente jmessenger(jabberit_messenger)

  • Property svn:executable set to *
Line 
1/*
2 *      Jeti, a Java Jabber client, Copyright (C) 2001 E.S. de Boer 
3 *
4 *  This program is free software; you can redistribute it and/or modify
5 *  it under the terms of the GNU General Public License as published by
6 *  the Free Software Foundation; either version 2 of the License, or
7 *  (at your option) any later version.
8 *
9 *  This program is distributed in the hope that it will be useful,
10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *      GNU General Public License for more details.
13 *
14 *  You should have received a copy of the GNU General Public License
15 *  along with this program; if not, write to the Free Software
16 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 *
18 *      For questions, comments etc,
19 *      use the website at http://jeti.jabberstudio.org
20 *  or mail/IM me at jeti@jabber.org
21 */
22
23package nu.fw.jeti.util;
24
25import java.awt.Container;
26import java.awt.HeadlessException;
27
28import javax.swing.Icon;
29import javax.swing.JOptionPane;
30
31/**
32 * This class wraps Joptionpane to provide non blocking popups
33 * @author E.S. de Boer
34 */
35public class Popups
36{
37        static private Container main;
38
39    public Popups(Container window)
40    {
41                main = window;
42        }
43
44        public static void errorPopup(String error,String title)
45        {
46                popup(error,title,JOptionPane.ERROR_MESSAGE);
47                //JOptionPane.showMessageDialog(main,error,title,JOptionPane.ERROR_MESSAGE);
48        }
49
50        public static void criticalErrorPopup(String error,String title)
51        {
52                //popup(error,title,javax.swing.JOptionPane.ERROR_MESSAGE);
53                JOptionPane.showMessageDialog(main,error,title,JOptionPane.ERROR_MESSAGE);
54        }
55
56        public static void messagePopup(String message,String title)
57        {
58                popup(message,title,JOptionPane.INFORMATION_MESSAGE);
59                //JOptionPane.showMessageDialog(main,error,title,JOptionPane.ERROR_MESSAGE);
60        }
61
62        public static void popup(String text,String title,int message)
63        {
64                if(main!=null)main.show();// toFront();
65                showMessageDialog(text,title,message);
66        }
67       
68        public static void showOptionDialog(Object message, String title, int optionType, int messageType,
69                                Icon icon,final Object[] options, Object initialValue,OptionChoosed choosed)
70        {
71                if(main!=null)main.show();
72                JOptionPaneNonModal.showOptionDialog( main,message,title,optionType,messageType,icon,options,initialValue ,choosed);           
73        }
74                               
75
76        /*
77        static class TempThread extends Thread
78        {
79                private String title;
80                private String text;
81                private int message;
82
83                public TempThread(String text, String title,int message)
84                {
85                    this.text =text;
86                        this.title =title;
87                        this.message =message;
88                }
89
90                public void run()
91                {
92                        popup(text,title,message);
93                }
94        }
95        */
96       
97        /**
98         * Brings up a dialog that displays a message using a default
99         * icon determined by the <code>messageType</code> parameter.
100         *
101         * @param parentComponent determines the <code>Frame</code>
102         *              in which the dialog is displayed; if <code>null</code>,
103         *              or if the <code>parentComponent</code> has no
104         *              <code>Frame</code>, a default <code>Frame</code> is used
105         * @param message   the <code>Object</code> to display
106         * @param title     the title string for the dialog
107         * @param messageType the type of message to be displayed:
108         *                  <code>ERROR_MESSAGE</code>,
109         *                      <code>INFORMATION_MESSAGE</code>,
110         *                      <code>WARNING_MESSAGE</code>,
111         *                  <code>QUESTION_MESSAGE</code>,
112         *                      or <code>PLAIN_MESSAGE</code>
113         * @exception HeadlessException if
114         *   <code>GraphicsEnvironment.isHeadless</code> returns
115         *   <code>true</code>
116         * @see java.awt.GraphicsEnvironment#isHeadless
117         */
118        public static void showMessageDialog(Object message, String title, int messageType)
119        {
120                showMessageDialog(message, title, messageType, null);
121        }
122
123        /**
124         * Brings up a dialog displaying a message, specifying all parameters.
125         *
126         * @param parentComponent determines the <code>Frame</code> in which the
127         *                      dialog is displayed; if <code>null</code>,
128         *                      or if the <code>parentComponent</code> has no
129         *                      <code>Frame</code>, a
130         *                  default <code>Frame</code> is used
131         * @param message   the <code>Object</code> to display
132         * @param title     the title string for the dialog
133         * @param messageType the type of message to be displayed:
134         *                  <code>ERROR_MESSAGE</code>,
135         *                      <code>INFORMATION_MESSAGE</code>,
136         *                      <code>WARNING_MESSAGE</code>,
137         *                  <code>QUESTION_MESSAGE</code>,
138         *                      or <code>PLAIN_MESSAGE</code>
139         * @param icon      an icon to display in the dialog that helps the user
140         *                  identify the kind of message that is being displayed
141         * @exception HeadlessException if
142         *   <code>GraphicsEnvironment.isHeadless</code> returns
143         *   <code>true</code>
144         * @see java.awt.GraphicsEnvironment#isHeadless
145         */
146        public static void showMessageDialog(   Object message, String title, int messageType, Icon icon)
147        {
148                showOptionDialog(message, title, JOptionPane.DEFAULT_OPTION,
149                                                 messageType, icon, null, null,null);
150        }
151       
152        public interface OptionChoosed
153        {
154                void optionChoosed(int option);
155        }
156
157}
158
159/*
160 * Overrides for emacs
161 * Local variables:
162 * tab-width: 4
163 * End:
164 */
Note: See TracBrowser for help on using the repository browser.