KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > base > WizardTextField


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.core.gui.base;
17
18 import java.awt.GridBagConstraints JavaDoc;
19 import java.awt.GridBagLayout JavaDoc;
20 import java.awt.Insets JavaDoc;
21
22 import javax.swing.JComponent JavaDoc;
23 import javax.swing.JLabel JavaDoc;
24 import javax.swing.JPanel JavaDoc;
25
26
27 public class WizardTextField extends JPanel JavaDoc {
28     private GridBagLayout JavaDoc layout;
29     private int y = 0;
30
31     public WizardTextField() {
32         setOpaque(false);
33         layout = new GridBagLayout JavaDoc();
34         setLayout(layout);
35     }
36
37     public void addLabel(JLabel JavaDoc label) {
38         GridBagConstraints JavaDoc c = new GridBagConstraints JavaDoc();
39
40         c.gridx = 0;
41         c.gridy = y;
42         c.weightx = 0.0;
43         c.anchor = GridBagConstraints.WEST;
44         c.insets = new Insets JavaDoc(0, 0, 0, 20);
45         layout.setConstraints(label, c);
46         add(label);
47     }
48
49     public void addTextField(JComponent JavaDoc component) {
50         GridBagConstraints JavaDoc c = new GridBagConstraints JavaDoc();
51
52         c.gridx = 1;
53         c.weightx = 1.0;
54         c.gridy = y;
55         c.fill = GridBagConstraints.HORIZONTAL;
56         c.insets = new Insets JavaDoc(0, 0, 0, 0);
57         c.anchor = GridBagConstraints.EAST;
58         c.gridwidth = GridBagConstraints.REMAINDER;
59         layout.setConstraints(component, c);
60         add(component);
61     }
62
63     public void addExample(JLabel JavaDoc example) {
64         y += 1;
65
66         GridBagConstraints JavaDoc c = new GridBagConstraints JavaDoc();
67
68         c.gridx = 1;
69
70         c.gridy = y;
71         c.weightx = 0.0;
72         c.insets = new Insets JavaDoc(0, 10, 10, 0);
73         c.anchor = GridBagConstraints.WEST;
74         c.fill = GridBagConstraints.NONE;
75         layout.setConstraints(example, c);
76         add(example);
77
78         y += 1;
79     }
80
81     public void addEmptyExample() {
82         y += 2;
83     }
84 }
85
Popular Tags