01: /*
02: * SQLeonardo :: java database frontend
03: * Copyright (C) 2004 nickyb@users.sourceforge.net
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * as published by the Free Software Foundation; either version 2
08: * of the License, or (at your option) any later version.
09: *
10: * This program is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU General Public License for more details.
14: *
15: * You should have received a copy of the GNU General Public License
16: * along with this program; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18: *
19: */
20:
21: package nickyb.sqleonardo.common.gui;
22:
23: import java.awt.BorderLayout;
24: import java.awt.Component;
25: import java.awt.LayoutManager;
26:
27: import javax.swing.JPanel;
28:
29: public class BorderLayoutPanel extends JPanel {
30: public BorderLayoutPanel() {
31: this (0, 0);
32: }
33:
34: public BorderLayoutPanel(int hgap, int vgap) {
35: super (new BorderLayout(hgap, vgap));
36: }
37:
38: public final void add(Component comp, Object constraints) {
39: if (!(this .getLayout() instanceof BorderLayout))
40: super .setLayout(new BorderLayout());
41:
42: super .add(comp, constraints);
43: }
44:
45: public final void setLayout(LayoutManager mgr) {
46: if (!(mgr instanceof BorderLayout))
47: throw new IllegalArgumentException(
48: "this is a BorderLayout panel");
49:
50: super .setLayout(mgr);
51: }
52:
53: public final void setComponentNorth(Component comp) {
54: add(comp, BorderLayout.NORTH);
55: }
56:
57: public final void setComponentSouth(Component comp) {
58: add(comp, BorderLayout.SOUTH);
59: }
60:
61: public final void setComponentCenter(Component comp) {
62: add(comp, BorderLayout.CENTER);
63: }
64:
65: public final void setComponentEast(Component comp) {
66: add(comp, BorderLayout.EAST);
67: }
68:
69: public final void setComponentWest(Component comp) {
70: add(comp, BorderLayout.WEST);
71: }
72: }
|