KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > adminGui > widget > TitledPanel


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
// $Id: TitledPanel.java,v 1.1 2003/03/24 08:36:56 per_nyfelt Exp $
8
package org.ozoneDB.adminGui.widget;
9
10 import org.ozoneDB.adminGui.res.Settings;
11
12 import javax.swing.*;
13 import javax.swing.border.Border JavaDoc;
14 import java.awt.*;
15
16 /**
17  * A JPanel with some color specified and parametirized titles
18  */

19 public class TitledPanel extends JPanel {
20
21     public TitledPanel(String JavaDoc title, Color lineColor, int thickness) {
22         this(new BorderLayout(), title, lineColor, thickness);
23     }
24
25     public TitledPanel(String JavaDoc title) {
26         this(new BorderLayout(), title, Settings.COLOR_COBALT, 2);
27     }
28
29     public TitledPanel(LayoutManager manager, String JavaDoc title) {
30         this(manager, title, Settings.COLOR_COBALT, 2);
31     }
32
33     public TitledPanel(LayoutManager manager, String JavaDoc title, Color lineColor, int thickness) {
34         super(manager);
35         setBorder(createTitledBorder(title, lineColor, thickness));
36     }
37
38     private Border JavaDoc createTitledBorder(String JavaDoc title, Color lineColor, int thickness) {
39
40         StringBuffer JavaDoc titleBuf = new StringBuffer JavaDoc();
41         titleBuf.append(" ");
42         titleBuf.append(title);
43         titleBuf.append(" ");
44
45         Border JavaDoc border = BorderFactory.createLineBorder(lineColor, thickness);
46         return BorderFactory.createTitledBorder(border, titleBuf.toString());
47     }
48
49
50 }
51
Popular Tags