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.addressbook.gui.util;
17:
18: import java.awt.Component;
19: import java.awt.GridBagConstraints;
20: import java.awt.GridBagLayout;
21: import java.awt.Insets;
22:
23: import javax.swing.Box;
24: import javax.swing.JComponent;
25: import javax.swing.JPanel;
26:
27: public class LabelTextFieldPanel extends JPanel {
28:
29: private GridBagLayout layout;
30:
31: private int y = 0;
32:
33: public LabelTextFieldPanel() {
34: layout = new GridBagLayout();
35: setLayout(layout);
36: }
37:
38: public void addLabel(JComponent label) {
39: GridBagConstraints c = new GridBagConstraints();
40:
41: c.gridx = 0;
42: c.gridy = y;
43: c.weightx = 0.0;
44: c.anchor = GridBagConstraints.WEST;
45: c.fill = GridBagConstraints.HORIZONTAL;
46: c.insets = new Insets(0, 0, 0, 11);
47: layout.setConstraints(label, c);
48: add(label);
49: }
50:
51: public void addTextField(JComponent component) {
52: GridBagConstraints c = new GridBagConstraints();
53:
54: c.gridx = 1;
55: c.weightx = 1.0;
56: c.gridy = y;
57: c.fill = GridBagConstraints.HORIZONTAL;
58: c.insets = new Insets(5, 0, 0, 0);
59: c.anchor = GridBagConstraints.EAST;
60: c.gridwidth = GridBagConstraints.REMAINDER;
61: layout.setConstraints(component, c);
62: add(component);
63:
64: y += 1;
65: }
66:
67: public void addSeparator() {
68: GridBagConstraints c = new GridBagConstraints();
69: c.gridx = 0;
70: c.weightx = 1.0;
71: c.gridy = y;
72: c.fill = GridBagConstraints.HORIZONTAL;
73: c.insets = new Insets(0, 0, 0, 0);
74: c.gridwidth = GridBagConstraints.REMAINDER;
75:
76: Component component = Box.createVerticalStrut(11);
77: layout.setConstraints(component, c);
78: add(component);
79:
80: y += 1;
81: }
82: }
|