001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.core.gui.base;
017:
018: import java.awt.Component;
019: import java.awt.LayoutManager;
020:
021: import javax.swing.BorderFactory;
022: import javax.swing.BoxLayout;
023: import javax.swing.JPanel;
024:
025: public class CPanel extends JPanel {
026: static int size = 10;
027: JPanel panel;
028: JPanel innerPanel;
029:
030: public CPanel(String title) {
031: super ();
032: setBorder(BorderFactory.createEmptyBorder(size, size, size,
033: size));
034:
035: innerPanel = new JPanel();
036: innerPanel.setBorder(javax.swing.BorderFactory
037: .createTitledBorder(javax.swing.BorderFactory
038: .createEtchedBorder(), title));
039: innerPanel
040: .setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS));
041:
042: panel = new JPanel();
043: panel.setBorder(BorderFactory.createEmptyBorder(size, size,
044: size, size));
045: panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
046:
047: setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
048:
049: innerPanel.add(panel);
050:
051: //add( panel, BorderLayout.CENTER );
052: super .add(innerPanel);
053: }
054:
055: public CPanel(String title, boolean b) {
056: super ();
057: setBorder(BorderFactory.createEmptyBorder(size, size, size,
058: size));
059:
060: innerPanel = new JPanel();
061: innerPanel.setBorder(javax.swing.BorderFactory
062: .createTitledBorder(javax.swing.BorderFactory
063: .createEtchedBorder(), title));
064:
065: if (b == true) {
066: innerPanel.setLayout(new BoxLayout(innerPanel,
067: BoxLayout.Y_AXIS));
068: } else {
069: innerPanel.setLayout(new BoxLayout(innerPanel,
070: BoxLayout.X_AXIS));
071: }
072:
073: panel = new JPanel();
074: panel.setBorder(BorderFactory.createEmptyBorder(size, size,
075: size, size));
076:
077: if (b == true) {
078: panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
079: } else {
080: panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
081: }
082:
083: if (b == true) {
084: setLayout(new BoxLayout(this , BoxLayout.Y_AXIS));
085: } else {
086: setLayout(new BoxLayout(this , BoxLayout.X_AXIS));
087: }
088:
089: innerPanel.add(panel);
090:
091: //add( panel, BorderLayout.CENTER );
092: super .add(innerPanel);
093: }
094:
095: public Component add(Component comp) {
096: return panel.add(comp);
097: }
098:
099: public Component add(Component comp, int index) {
100: return panel.add(comp, index);
101: }
102:
103: public void setInnerLayout(LayoutManager mgr) {
104: panel.setLayout(mgr);
105: }
106: }
|