1 package org.wcb.gui.component;
2
3 import javax.swing.*;
4 import java.awt.*;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
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 }