• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  *             of Java bytecode.
4  *
5  * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu)
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License as published by the Free
9  * Software Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 package proguard.gui;
22 
23 import javax.swing.*;
24 import java.awt.*;
25 import java.lang.reflect.InvocationTargetException;
26 
27 
28 /**
29  * This <code>Runnable</code> can show a message dialog.
30  *
31  * @author Eric Lafortune
32  */
33 final class MessageDialogRunnable implements Runnable
34 {
35     private final Component parentComponent;
36     private final Object    message;
37     private final String    title;
38     private final int       messageType;
39 
40 
41     /**
42      * Creates a new MessageDialogRunnable object.
43      * @see JOptionPane#showMessageDialog(Component, Object, String, int)
44      */
showMessageDialog(Component parentComponent, Object message, String title, int messageType)45     public static void showMessageDialog(Component parentComponent,
46                                          Object    message,
47                                          String    title,
48                                          int       messageType)
49     {
50         try
51         {
52             SwingUtil.invokeAndWait(new MessageDialogRunnable(parentComponent,
53                                                               message,
54                                                               title,
55                                                               messageType));
56         }
57         catch (Exception e)
58         {
59             // Nothing.
60         }
61     }
62 
63 
64     /**
65      * Creates a new MessageDialogRunnable object.
66      * @see JOptionPane#showMessageDialog(Component, Object, String, int)
67      */
MessageDialogRunnable(Component parentComponent, Object message, String title, int messageType)68     public MessageDialogRunnable(Component parentComponent,
69                                  Object    message,
70                                  String    title,
71                                  int       messageType)
72     {
73         this.parentComponent = parentComponent;
74         this.message         = message;
75         this.title           = title;
76         this.messageType     = messageType;
77     }
78 
79 
80 
81     // Implementation for Runnable.
82 
run()83     public void run()
84     {
85         JOptionPane.showMessageDialog(parentComponent,
86                                       message,
87                                       title,
88                                       messageType);
89     }
90 }
91