001: /**
002: * Caption: Zaval Java Resource Editor
003: * $Revision: 0.37 $
004: * $Date: 2002/03/28 9:24:42 $
005: *
006: * @author: Victor Krapivin
007: * @version: 1.3
008: *
009: * Zaval JRC Editor is a visual editor which allows you to manipulate
010: * localization strings for all Java based software with appropriate
011: * support embedded.
012: *
013: * For more info on this product read Zaval Java Resource Editor User's Guide
014: * (It comes within this package).
015: * The latest product version is always available from the product's homepage:
016: * http://www.zaval.org/products/jrc-editor/
017: * and from the SourceForge:
018: * http://sourceforge.net/projects/zaval0002/
019: *
020: * Contacts:
021: * Support : support@zaval.org
022: * Change Requests : change-request@zaval.org
023: * Feedback : feedback@zaval.org
024: * Other : info@zaval.org
025: *
026: * Copyright (C) 2001-2002 Zaval Creative Engineering Group (http://www.zaval.org)
027: *
028: * This program is free software; you can redistribute it and/or
029: * modify it under the terms of the GNU General Public License
030: * (version 2) as published by the Free Software Foundation.
031: *
032: * This program is distributed in the hope that it will be useful,
033: * but WITHOUT ANY WARRANTY; without even the implied warranty of
034: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
035: * GNU General Public License for more details.
036: *
037: * You should have received a copy of the GNU General Public License
038: * along with this program; if not, write to the Free Software
039: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
040: *
041: */package org.zaval.awt;
042:
043: import java.awt.*;
044: import java.util.*;
045:
046: public class StatusBarElement extends Panel {
047: private int percent = -1;
048: private int type = 1;
049: private Insets ins = new Insets(1, 3, 1, 3);
050: private Dimension pref = null;
051:
052: public StatusBarElement(Component c, int p, Dimension pref) {
053: setLayout(new BorderLayout(1, 0));
054: if (c != null)
055: add("Center", c);
056: percent = p;
057: this .pref = pref;
058: }
059:
060: public StatusBarElement(Component c, int p) {
061: this (c, p, null);
062: }
063:
064: public void setType(int t) {
065: if (t == type)
066: return;
067: type = t;
068: repaint();
069: }
070:
071: public int getPercent() {
072: return percent;
073: }
074:
075: public Insets insets() {
076: return ins;
077: }
078:
079: public void paint(Graphics gr) {
080: super .paint(gr);
081: Dimension d = size();
082: switch (type) {
083: case 1:
084: gr.setColor(Color.gray);
085: gr.drawLine(0, 0, d.width - 1, 0);
086: gr.drawLine(0, 0, 0, d.height - 1);
087:
088: gr.setColor(Color.white);
089: gr.drawLine(d.width - 1, 0, d.width - 1, d.height - 1);
090: gr.drawLine(d.width - 1, d.height - 1, 0, d.height - 1);
091: break;
092: case 2:
093: gr.setColor(Color.white);
094: gr.drawLine(0, 0, d.width - 1, 0);
095: gr.drawLine(0, 0, 0, d.height - 1);
096:
097: gr.setColor(Color.gray);
098: gr.drawLine(d.width - 1, 0, d.width - 1, d.height - 1);
099: gr.drawLine(d.width - 1, d.height - 1, 0, d.height - 1);
100: }
101: }
102:
103: public Dimension preferredSize() {
104: if (pref != null)
105: return new Dimension(pref.width, pref.height);
106: return super.preferredSize();
107: }
108: }
|