01: //WebOnSwing - Web Application Framework
02: //Copyright (C) 2004 Fernando Damian Petrola
03: //
04: //This library is free software; you can redistribute it and/or
05: //modify it under the terms of the GNU Lesser General Public
06: //License as published by the Free Software Foundation; either
07: //version 2.1 of the License, or (at your option) any later version.
08: //
09: //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 USA
17:
18: package weblog;
19:
20: import java.awt.*;
21:
22: import javax.swing.*;
23:
24: public class MultipleFieldsPanel extends JPanel {
25: protected JPanel fieldsPanel;
26: protected JButton submitButton;
27: protected JComponent titleComponent;
28:
29: public MultipleFieldsPanel(JComponent aTitleComponent) {
30: titleComponent = aTitleComponent;
31: initialize();
32: }
33:
34: protected void initialize() {
35: setName("MultipleFieldsPanel");
36: setLayout(new BorderLayout());
37:
38: titleComponent.setName("titleLabel");
39:
40: fieldsPanel = new JPanel();
41: fieldsPanel.setName("fieldsPanel");
42: fieldsPanel.setLayout(new GridLayout(0, 1));
43: fieldsPanel.setBackground(new Color(0xFF, 0xF9, 0xEE));
44:
45: submitButton = submitButton = new JButton();
46: submitButton.setName("submitButton");
47: submitButton.setText("Submit");
48: submitButton.setPreferredSize(new Dimension(102, 30));
49: submitButton.setBackground(new Color(0xD1, 0xDC, 0xEB));
50:
51: add(titleComponent, BorderLayout.NORTH);
52:
53: JScrollPane sp = new JScrollPane(fieldsPanel);
54: add(sp, BorderLayout.CENTER);
55: add(submitButton, BorderLayout.SOUTH);
56: setBackground(new Color(0xF9, 0xF9, 0xF9));
57: setSize(513, 200);
58: }
59:
60: public void addFieldPanel(String aFieldName, JComponent aComponent) {
61: JPanel panel = new JPanel();
62: panel.setName("fieldPanel");
63:
64: JLabel label = new JLabel();
65: label.setText(aFieldName);
66: label.setName("label");
67:
68: aComponent.setName("field");
69:
70: panel.setLayout(new BorderLayout());
71: panel.add(label, BorderLayout.WEST);
72: panel.add(aComponent, BorderLayout.CENTER);
73: panel.setBackground(new Color(0xFF, 0xF9, 0xEE));
74:
75: fieldsPanel.add(panel);
76: }
77:
78: public JPanel getFieldsPanel() {
79: return fieldsPanel;
80: }
81:
82: public JButton getSubmitButton() {
83: return submitButton;
84: }
85:
86: public void setFieldsPanel(JPanel aPanel) {
87: fieldsPanel = aPanel;
88: }
89:
90: public void setSubmitButton(JButton aButton) {
91: submitButton = aButton;
92: }
93: }
|