KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > apps > svgbrowser > OptionPanel


1 /*
2
3    Copyright 2002-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 package org.apache.batik.apps.svgbrowser;
19
20 import java.awt.BorderLayout JavaDoc;
21 import java.awt.Component JavaDoc;
22 import java.awt.FlowLayout JavaDoc;
23 import java.awt.LayoutManager JavaDoc;
24 import java.awt.event.ActionEvent JavaDoc;
25 import java.util.Locale JavaDoc;
26 import java.util.ResourceBundle JavaDoc;
27
28 import javax.swing.AbstractAction JavaDoc;
29 import javax.swing.JButton JavaDoc;
30 import javax.swing.JDialog JavaDoc;
31 import javax.swing.JOptionPane JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33
34 import org.apache.batik.util.gui.resource.ResourceManager;
35
36 /**
37  * This class represents a panel to present users with options.
38  *
39  * @author <a HREF="mailto:deweese@apache.org">Thomas DeWeese</a>
40  * @version $Id: OptionPanel.java,v 1.4 2004/08/18 07:12:27 vhardy Exp $
41  */

42 public class OptionPanel extends JPanel JavaDoc {
43
44     /**
45      * The gui resources file name
46      */

47     public final static String JavaDoc RESOURCES =
48         "org.apache.batik.apps.svgbrowser.resources.GUI";
49
50     /**
51      * The resource bundle
52      */

53     protected static ResourceBundle JavaDoc bundle;
54
55     /**
56      * The resource manager
57      */

58     protected static ResourceManager resources;
59
60     static {
61         bundle = ResourceBundle.getBundle(RESOURCES, Locale.getDefault());
62         resources = new ResourceManager(bundle);
63     }
64
65     /**
66      * Creates a new panel.
67      */

68     public OptionPanel(LayoutManager JavaDoc layout) {
69     super(layout);
70     }
71
72     /**
73      * This class is modal dialog to choose the jpeg encoding quality.
74      */

75     public static class Dialog extends JDialog JavaDoc {
76
77     /**
78      * The 'ok' button.
79      */

80     protected JButton JavaDoc ok;
81
82     /**
83      * The 'ok' button.
84      */

85     protected JPanel JavaDoc panel;
86
87     public Dialog(Component JavaDoc parent, String JavaDoc title, JPanel JavaDoc panel) {
88         super(JOptionPane.getFrameForComponent(parent), title);
89         setModal(true);
90         this.panel = panel;
91         getContentPane().add(panel, BorderLayout.CENTER);
92         getContentPane().add(createButtonPanel(), BorderLayout.SOUTH);
93     }
94
95     /**
96      * Creates the button panel.
97      */

98     protected JPanel JavaDoc createButtonPanel() {
99         JPanel JavaDoc panel = new JPanel JavaDoc(new FlowLayout JavaDoc());
100         ok = new JButton JavaDoc(resources.getString("OKButton.text"));
101         ok.addActionListener(new OKButtonAction());
102         panel.add(ok);
103         return panel;
104     }
105
106     /**
107      * The action associated to the 'ok' button.
108      */

109     protected class OKButtonAction extends AbstractAction JavaDoc {
110
111         public void actionPerformed(ActionEvent JavaDoc evt) {
112         dispose();
113         }
114     }
115     }
116 }
117
118
Popular Tags