1   package org.wcb.gui.component;
2   
3   import javax.swing.*;
4   import java.awt.*;
5   
6   /**
7    * <small>
8    * Copyright (c)  2006  wbogaardt.
9    * This library is free software; you can redistribute it and/or
10   * modify it under the terms of the GNU Lesser General Public
11   * License as published by the Free Software Foundation; either
12   * version 2.1 of the License, or (at your option) any later version.
13   *
14   * This library is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this library; if not, write to the Free Software
21   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22   * <p/>
23   * $File:  $ <br>
24   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Mar 30, 2006 5:05:39 PM $ <br>
25   * </small>
26   *
27   * @author wbogaardt
28   * @version 1
29   *          Date: Mar 30, 2006
30   *          Time: 5:05:39 PM
31   */
32  
33  public class JXTitlePanel extends JPanel {
34  
35      private JPanel titlePanel;
36      private JPanel mainPanel;
37  
38      public JXTitlePanel() {
39          this(null);
40      }
41  
42      public JXTitlePanel(String title) {
43          //this(title, new Color(0xffa000));
44          this(title, new Color(0x522aec));
45      }
46  
47      public JXTitlePanel(String title, Color color) {
48          this(title, color, null, new BorderLayout());
49      }
50  
51      public JXTitlePanel(ImageIcon icon, Color color) {
52          this("", color, icon, new BorderLayout());
53      }
54  
55      public JXTitlePanel(String title, Color color, ImageIcon icon) {
56          this(title, color, icon, new BorderLayout());
57      }
58      
59      public JXTitlePanel(String title, Color color, ImageIcon icon, LayoutManager layout) {
60          mainPanel = new JPanel(layout);
61          titlePanel = new TitlePanel(title, icon, color);
62          super.setLayout(new BorderLayout());
63          super.add(titlePanel, BorderLayout.NORTH);
64          super.add(mainPanel, BorderLayout.CENTER);
65          initLayout();
66      }
67  
68      private void initLayout() {
69          super.setLayout(new BorderLayout());
70          super.add(titlePanel, BorderLayout.NORTH);
71          super.add(mainPanel, BorderLayout.CENTER);
72      }
73  
74      public void setLayout(LayoutManager mngr) {
75          if (mainPanel == null) {
76              mainPanel = new JPanel();
77          }
78          mainPanel.setLayout(mngr);
79      }
80  
81      public Component add(Component comp) {
82          return mainPanel.add(comp);
83      }
84  
85      public Component add(String name, Component comp) {
86          return mainPanel.add(name, comp);
87      }
88  
89      public Component add(Component comp, int indx) {
90          return mainPanel.add(comp, indx);
91      }
92  
93      public void add(Component comp, Object objConstraint) {
94          mainPanel.add(comp, objConstraint);
95      }
96  
97      public void add(Component comp, Object objConstraint, int indx) {
98          mainPanel.add(comp, objConstraint, indx);
99      }
100 
101 
102 }