001: /*
002: * StatusBarLabel.java
003: *
004: * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU General Public License
008: * as published by the Free Software Foundation; either version 2
009: * of the License, or any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
019: *
020: */
021:
022: package org.underworldlabs.swing;
023:
024: import java.awt.Color;
025: import java.awt.Dimension;
026: import java.awt.Graphics;
027: import javax.swing.JLabel;
028:
029: /* ----------------------------------------------------------
030: * CVS NOTE: Changes to the CVS repository prior to the
031: * release of version 3.0.0beta1 has meant a
032: * resetting of CVS revision numbers.
033: * ----------------------------------------------------------
034: */
035:
036: /**
037: * Status bar panel label.
038: *
039: * @author Takis Diakoumis
040: * @version $Revision: 1.4 $
041: * @date $Date: 2006/05/14 06:56:07 $
042: */
043: public class StatusBarLabel extends JLabel {
044:
045: /** Indicates to paint the left border */
046: private boolean paintLeft;
047:
048: /** Indicates to paint the right border */
049: private boolean paintRight;
050:
051: /** Indicates to paint the top border */
052: private boolean paintTop;
053:
054: /** Indicates to paint the bottom border */
055: private boolean paintBottom;
056:
057: /** the border colour */
058: private Color borderColour;
059:
060: /** the label height */
061: private int height;
062:
063: public StatusBarLabel(boolean paintTop, boolean paintLeft,
064: boolean paintBottom, boolean paintRight) {
065: this (paintTop, paintLeft, paintBottom, paintRight, 20);
066: }
067:
068: public StatusBarLabel(boolean paintTop, boolean paintLeft,
069: boolean paintBottom, boolean paintRight, int height) {
070: this .paintTop = paintTop;
071: this .paintLeft = paintLeft;
072: this .paintBottom = paintBottom;
073: this .paintRight = paintRight;
074: this .height = height;
075: setVerticalAlignment(JLabel.CENTER);
076: borderColour = GUIUtils.getDefaultBorderColour();
077: }
078:
079: public void paintComponent(Graphics g) {
080: super .paintComponent(g);
081: g.setColor(borderColour);
082:
083: int width = getWidth();
084: int height = getHeight();
085:
086: if (paintTop) {
087: g.drawLine(0, 0, width, 0);
088: }
089: if (paintBottom) {
090: g.drawLine(0, height - 1, width, height - 1);
091: }
092:
093: if (paintLeft) {
094: g.drawLine(0, 0, 0, height);
095: }
096: if (paintRight) {
097: g.drawLine(width - 1, 0, width - 1, height);
098: }
099:
100: }
101:
102: }
|