01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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;
19: import java.awt.GridBagLayout;
20: import java.awt.Insets;
21:
22: import javax.swing.JComponent;
23: import javax.swing.JLabel;
24: import javax.swing.JPanel;
25:
26: public class WizardTextField extends JPanel {
27: private GridBagLayout layout;
28: private int y = 0;
29:
30: public WizardTextField() {
31: setOpaque(false);
32: layout = new GridBagLayout();
33: setLayout(layout);
34: }
35:
36: public void addLabel(JLabel label) {
37: GridBagConstraints c = new GridBagConstraints();
38:
39: c.gridx = 0;
40: c.gridy = y;
41: c.weightx = 0.0;
42: c.anchor = GridBagConstraints.WEST;
43: c.insets = new Insets(0, 0, 0, 20);
44: layout.setConstraints(label, c);
45: add(label);
46: }
47:
48: public void addTextField(JComponent component) {
49: GridBagConstraints c = new GridBagConstraints();
50:
51: c.gridx = 1;
52: c.weightx = 1.0;
53: c.gridy = y;
54: c.fill = GridBagConstraints.HORIZONTAL;
55: c.insets = new Insets(0, 0, 0, 0);
56: c.anchor = GridBagConstraints.EAST;
57: c.gridwidth = GridBagConstraints.REMAINDER;
58: layout.setConstraints(component, c);
59: add(component);
60: }
61:
62: public void addExample(JLabel example) {
63: y += 1;
64:
65: GridBagConstraints c = new GridBagConstraints();
66:
67: c.gridx = 1;
68:
69: c.gridy = y;
70: c.weightx = 0.0;
71: c.insets = new Insets(0, 10, 10, 0);
72: c.anchor = GridBagConstraints.WEST;
73: c.fill = GridBagConstraints.NONE;
74: layout.setConstraints(example, c);
75: add(example);
76:
77: y += 1;
78: }
79:
80: public void addEmptyExample() {
81: y += 2;
82: }
83: }
|