KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > tools > admin > InputFormPanel


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA.
18  *
19  * Initial developer(s): Alexander Fedorowicz
20  * Contributor(s):
21  */

22 package org.objectweb.joram.client.tools.admin;
23
24 import javax.swing.*;
25 import java.awt.*;
26
27
28 public class InputFormPanel extends JPanel {
29   public InputFormPanel(JLabel[] labels, JTextField[] textFields) {
30     GridBagLayout gridbag = new GridBagLayout();
31
32     setLayout(gridbag);
33
34     GridBagConstraints c = new GridBagConstraints();
35     c.anchor = GridBagConstraints.EAST;
36     int numLabels = labels.length;
37
38     for (int i = 0; i < numLabels; i++) {
39       c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
40
c.fill = GridBagConstraints.NONE; //reset to default
41
c.weightx = 0.0; //reset to default
42
gridbag.setConstraints(labels[i], c);
43       add(labels[i]);
44
45       c.gridwidth = GridBagConstraints.REMAINDER; //end row
46
c.fill = GridBagConstraints.HORIZONTAL;
47       c.weightx = 1.0;
48       gridbag.setConstraints(textFields[i], c);
49       add(textFields[i]);
50     }
51   }
52 }
53
Popular Tags