• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * ProGuard -- shrinking, optimization, obfuscation, and preverification
3  *             of Java bytecode.
4  *
5  * Copyright (c) 2002-2014 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 
26 
27 /**
28  * This <code>Runnable</code> can show a message dialog.
29  *
30  * @author Eric Lafortune
31  */
32 final class MessageDialogRunnable implements Runnable
33 {
34     private final Component parentComponent;
35     private final Object    message;
36     private final String    title;
37     private final int       messageType;
38 
39 
40     /**
41      * Creates a new MessageDialogRunnable object.
42      * @see JOptionPane#showMessageDialog(Component, Object, String, int)
43      */
showMessageDialog(Component parentComponent, Object message, String title, int messageType)44     public static void showMessageDialog(Component parentComponent,
45                                          Object    message,
46                                          String    title,
47                                          int       messageType)
48     {
49         try
50         {
51             SwingUtil.invokeAndWait(new MessageDialogRunnable(parentComponent,
52                                                               message,
53                                                               title,
54                                                               messageType));
55         }
56         catch (Exception e)
57         {
58             // Nothing.
59         }
60     }
61 
62 
63     /**
64      * Creates a new MessageDialogRunnable object.
65      * @see JOptionPane#showMessageDialog(Component, Object, String, int)
66      */
MessageDialogRunnable(Component parentComponent, Object message, String title, int messageType)67     public MessageDialogRunnable(Component parentComponent,
68                                  Object    message,
69                                  String    title,
70                                  int       messageType)
71     {
72         this.parentComponent = parentComponent;
73         this.message         = message;
74         this.title           = title;
75         this.messageType     = messageType;
76     }
77 
78 
79 
80     // Implementation for Runnable.
81 
run()82     public void run()
83     {
84         JOptionPane.showMessageDialog(parentComponent,
85                                       message,
86                                       title,
87                                       messageType);
88     }
89 }
90