KickJava   Java API By Example, From Geeks To Geeks.

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


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.Component JavaDoc;
19 import java.awt.LayoutManager JavaDoc;
20
21 import javax.swing.BorderFactory JavaDoc;
22 import javax.swing.BoxLayout JavaDoc;
23 import javax.swing.JPanel JavaDoc;
24
25
26
27 public class CPanel extends JPanel JavaDoc {
28     static int size = 10;
29     JPanel JavaDoc panel;
30     JPanel JavaDoc innerPanel;
31
32     public CPanel(String JavaDoc title) {
33         super();
34         setBorder(BorderFactory.createEmptyBorder(size, size, size, size));
35
36         innerPanel = new JPanel JavaDoc();
37         innerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
38                 javax.swing.BorderFactory.createEtchedBorder(), title));
39         innerPanel.setLayout(new BoxLayout JavaDoc(innerPanel, BoxLayout.Y_AXIS));
40
41         panel = new JPanel JavaDoc();
42         panel.setBorder(BorderFactory.createEmptyBorder(size, size, size, size));
43         panel.setLayout(new BoxLayout JavaDoc(panel, BoxLayout.Y_AXIS));
44
45         setLayout(new BoxLayout JavaDoc(this, BoxLayout.Y_AXIS));
46
47         innerPanel.add(panel);
48
49         //add( panel, BorderLayout.CENTER );
50
super.add(innerPanel);
51     }
52
53     public CPanel(String JavaDoc title, boolean b) {
54         super();
55         setBorder(BorderFactory.createEmptyBorder(size, size, size, size));
56
57         innerPanel = new JPanel JavaDoc();
58         innerPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
59                 javax.swing.BorderFactory.createEtchedBorder(), title));
60
61         if (b == true) {
62             innerPanel.setLayout(new BoxLayout JavaDoc(innerPanel, BoxLayout.Y_AXIS));
63         } else {
64             innerPanel.setLayout(new BoxLayout JavaDoc(innerPanel, BoxLayout.X_AXIS));
65         }
66
67         panel = new JPanel JavaDoc();
68         panel.setBorder(BorderFactory.createEmptyBorder(size, size, size, size));
69
70         if (b == true) {
71             panel.setLayout(new BoxLayout JavaDoc(panel, BoxLayout.Y_AXIS));
72         } else {
73             panel.setLayout(new BoxLayout JavaDoc(panel, BoxLayout.X_AXIS));
74         }
75
76         if (b == true) {
77             setLayout(new BoxLayout JavaDoc(this, BoxLayout.Y_AXIS));
78         } else {
79             setLayout(new BoxLayout JavaDoc(this, BoxLayout.X_AXIS));
80         }
81
82         innerPanel.add(panel);
83
84         //add( panel, BorderLayout.CENTER );
85
super.add(innerPanel);
86     }
87
88     public Component JavaDoc add(Component JavaDoc comp) {
89         return panel.add(comp);
90     }
91
92     public Component JavaDoc add(Component JavaDoc comp, int index) {
93         return panel.add(comp, index);
94     }
95
96     public void setInnerLayout(LayoutManager JavaDoc mgr) {
97         panel.setLayout(mgr);
98     }
99 }
100
Popular Tags