KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > tool > service > swing > ui > WizardPane


1 package org.apache.axis.tool.service.swing.ui;
2
3 import java.awt.LayoutManager JavaDoc;
4 import java.io.File JavaDoc;
5
6 import javax.swing.JFileChooser JavaDoc;
7 import javax.swing.JFrame JavaDoc;
8 import javax.swing.JOptionPane JavaDoc;
9 import javax.swing.JPanel JavaDoc;
10 import javax.swing.JTextArea JavaDoc;
11 import javax.swing.filechooser.FileFilter JavaDoc;
12
13 /*
14  * Copyright 2004,2005 The Apache Software Foundation.
15  *
16  * Licensed under the Apache License, Version 2.0 (the "License");
17  * you may not use this file except in compliance with the License.
18  * You may obtain a copy of the License at
19  *
20  * http://www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an "AS IS" BASIS,
24  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  */

28 public abstract class WizardPane extends JPanel JavaDoc {
29     protected JTextArea JavaDoc descriptionLabel;
30     protected JFrame JavaDoc ownerFrame;
31
32     protected int descWidth=400;
33     protected int descHeight=100;
34     protected int width=400;
35     protected int height=300;
36     protected int hgap=5;
37     protected int vgap=5;
38
39     protected WizardPane() {
40     }
41
42     protected WizardPane(JFrame JavaDoc ownerFrame) {
43         this.ownerFrame = ownerFrame;
44     }
45
46     protected WizardPane(boolean isDoubleBuffered) {
47         super(isDoubleBuffered);
48     }
49
50     protected WizardPane(LayoutManager JavaDoc layout) {
51         super(layout);
52     }
53
54     protected WizardPane(LayoutManager JavaDoc layout, boolean isDoubleBuffered) {
55         super(layout, isDoubleBuffered);
56     }
57
58     protected void initDescription(String JavaDoc desc){
59         this.descriptionLabel = new JTextArea JavaDoc(desc);
60         this.descriptionLabel.setOpaque(false);
61         this.descriptionLabel.setEditable(false);
62         this.descriptionLabel.setAutoscrolls(true);
63         this.descriptionLabel.setBounds(0,0,descWidth,descHeight);
64         this.add(this.descriptionLabel);
65     }
66
67     public abstract boolean validateValues();
68
69     protected void showErrorMessage(String JavaDoc message){
70         JOptionPane.showMessageDialog(this,message,"Error",JOptionPane.ERROR_MESSAGE);
71     }
72
73
74     protected String JavaDoc browseForAFile(final String JavaDoc extension){
75         String JavaDoc str="";
76         JFileChooser JavaDoc fc=new JFileChooser JavaDoc();
77         fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
78         fc.addChoosableFileFilter(new FileFilter JavaDoc(){
79             public boolean accept(File JavaDoc f) {
80                if (f.getName().endsWith(extension) || f.isDirectory())
81                    return true;
82                else
83                    return false;
84             }
85
86             public String JavaDoc getDescription() {
87                 return extension + " file filter ";
88             }
89         });
90
91         int returnVal = fc.showOpenDialog(this);
92         if(returnVal == JFileChooser.APPROVE_OPTION) {
93             str=fc.getSelectedFile().getAbsolutePath().trim();
94         }
95         return str;
96     }
97
98     protected String JavaDoc browseForAFolder(){
99         String JavaDoc str="";
100         JFileChooser JavaDoc fc=new JFileChooser JavaDoc();
101         fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
102         int returnVal = fc.showOpenDialog(this);
103         if(returnVal == JFileChooser.APPROVE_OPTION) {
104             str=fc.getSelectedFile().getAbsolutePath().trim();
105         }
106         return str;
107     }
108 }
109
Popular Tags