KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > swing > svg > SVGUserAgentGUIAdapter


1 /*
2
3    Copyright 1999-2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17 */

18
19 package org.apache.batik.swing.svg;
20
21 import java.awt.Component JavaDoc;
22 import javax.swing.JDialog JavaDoc;
23 import javax.swing.JOptionPane JavaDoc;
24 import org.apache.batik.util.gui.JErrorPane;
25
26 /**
27  * One line Class Desc
28  *
29  * Methods users may want to implement:
30  * displayMessage
31  *
32  * @author <a HREF="mailto:deweese@apache.org">deweese</a>
33  * @version $Id: SVGUserAgentGUIAdapter.java,v 1.4 2005/03/27 08:58:36 cam Exp $
34  */

35 public class SVGUserAgentGUIAdapter extends SVGUserAgentAdapter{
36     public Component JavaDoc parentComponent;
37     public SVGUserAgentGUIAdapter(Component JavaDoc parentComponent) {
38         this.parentComponent = parentComponent;
39     }
40
41     /**
42      * Displays an error message.
43      */

44     public void displayError(String JavaDoc message) {
45         JOptionPane JavaDoc pane = new JOptionPane JavaDoc(message, JOptionPane.ERROR_MESSAGE);
46         JDialog JavaDoc dialog = pane.createDialog(parentComponent, "ERROR");
47         dialog.setModal(false);
48         dialog.setVisible(true);
49     }
50
51     /**
52      * Displays an error resulting from the specified Exception.
53      */

54     public void displayError(Exception JavaDoc ex) {
55         JErrorPane pane = new JErrorPane(ex, JOptionPane.ERROR_MESSAGE);
56         JDialog JavaDoc dialog = pane.createDialog(parentComponent, "ERROR");
57         dialog.setModal(false);
58         dialog.setVisible(true);
59     }
60
61     /**
62      * Displays a message in the User Agent interface.
63      * The given message is typically displayed in a status bar.
64      */

65     public void displayMessage(String JavaDoc message) {
66         // Can't do anything don't have a status bar...
67
}
68
69     /**
70      * Shows an alert dialog box.
71      */

72     public void showAlert(String JavaDoc message) {
73         String JavaDoc str = "Script alert:\n" + message;
74         JOptionPane.showMessageDialog(parentComponent, str);
75     }
76
77     /**
78      * Shows a prompt dialog box.
79      */

80     public String JavaDoc showPrompt(String JavaDoc message) {
81         String JavaDoc str = "Script prompt:\n" + message;
82         return JOptionPane.showInputDialog(parentComponent, str);
83     }
84     
85     /**
86      * Shows a prompt dialog box.
87      */

88     public String JavaDoc showPrompt(String JavaDoc message, String JavaDoc defaultValue) {
89         String JavaDoc str = "Script prompt:\n" + message;
90         return (String JavaDoc)JOptionPane.showInputDialog
91             (parentComponent, str, null,
92              JOptionPane.PLAIN_MESSAGE,
93              null, null, defaultValue);
94     }
95
96     /**
97      * Shows a confirm dialog box.
98      */

99     public boolean showConfirm(String JavaDoc message) {
100         String JavaDoc str = "Script confirm:\n" + message;
101         return JOptionPane.showConfirmDialog
102             (parentComponent, str,
103              "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION;
104     }
105 };
106
Popular Tags