01: /* ===========================================================================
02: * $RCSfile: WarningDialog.java,v $
03: * ===========================================================================
04: *
05: * RetroGuard -- an obfuscation package for Java classfiles.
06: *
07: * Copyright (c) 1998-2006 Mark Welsh (markw@retrologic.com)
08: *
09: * This program can be redistributed and/or modified under the terms of the
10: * Version 2 of the GNU General Public License as published by the Free
11: * Software Foundation.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: */
19:
20: package COM.rl.util;
21:
22: import java.io.*;
23: import java.util.*;
24: import java.awt.*;
25: import java.awt.event.*;
26:
27: /**
28: * Warning dialog box.
29: *
30: * @author Mark Welsh
31: */
32: public class WarningDialog extends Dialog {
33: public WarningDialog(Frame f, String title, String[] phrases) {
34: this (f, title, phrases, false);
35: }
36:
37: public WarningDialog(Frame f, String title, String[] phrases,
38: boolean useTextArea) {
39: super (f, title, false);
40:
41: // Warning text
42: if (useTextArea) {
43: TextArea ta = new TextArea(10, 75);
44: //ta.setBackground(Color.lightGray);
45: ta.setEditable(false);
46: ta.setFont(new Font("Helvetica", Font.PLAIN, 12));
47: for (int i = 0; i < phrases.length; i++) {
48: ta.append(phrases[i]);
49: ta.append("\n");
50: }
51: add("Center", ta);
52: } else {
53: Panel left = new Panel() {
54: public Insets getInsets() {
55: return new Insets(4, 4, 4, 4);
56: }
57: };
58: left.setLayout(new GridLayout(0, 1));
59: left.setFont(new Font("Helvetica", Font.PLAIN, 12));
60: for (int i = 0; i < phrases.length; i++) {
61: left.add(new Label(phrases[i]));
62: }
63: add("Center", left);
64: }
65:
66: // Okay button
67: Button okay = new Button(" Okay ");
68: Panel right = new Panel();
69: right.setLayout(new FlowLayout(FlowLayout.CENTER));
70: right.add(okay);
71: add("East", right);
72:
73: // Set closing event handlers and pack to preferred size
74: addWindowListener(new WindowAdapter() {
75: public void windowClosing(WindowEvent e) {
76: setVisible(false);
77: }
78: });
79: okay.addActionListener(new ActionListener() {
80: public void actionPerformed(ActionEvent e) {
81: setVisible(false);
82: }
83: });
84: pack();
85:
86: // Position the dialog centrally in its parent
87: Rectangle bounds = f.getBounds();
88: Rectangle myBounds = getBounds();
89: setLocation(bounds.x + (bounds.width - myBounds.width) / 2,
90: bounds.y + (bounds.height - myBounds.height) / 2);
91: setVisible(true);
92: getToolkit().beep();
93: }
94: }
|