001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018: package org.columba.core.gui.base;
019:
020: import java.awt.BorderLayout;
021: import java.awt.Color;
022: import java.awt.Dimension;
023: import java.awt.Graphics;
024:
025: import javax.swing.JComponent;
026: import javax.swing.JLabel;
027: import javax.swing.JPanel;
028:
029: import com.jgoodies.forms.layout.CellConstraints;
030: import com.jgoodies.forms.layout.ColumnSpec;
031: import com.jgoodies.forms.layout.FormLayout;
032:
033: public class JStatusBar extends JPanel {
034:
035: private JPanel contentPanel = new JPanel();
036:
037: private FormLayout layout;
038:
039: private int layoutCoordinateX = 2;
040:
041: private int layoutCoordinateY = 2;
042:
043: public JStatusBar() {
044:
045: setLayout(new BorderLayout());
046: setPreferredSize(new Dimension(getWidth(), 23));
047:
048: JLabel resizeIconLabel = new JLabel(
049: new TriangleSquareWindowsCornerIcon());
050: resizeIconLabel.setOpaque(false);
051:
052: JPanel rightPanel = new JPanel();
053: rightPanel.setOpaque(false);
054: rightPanel.add(resizeIconLabel, BorderLayout.SOUTH);
055:
056: add(rightPanel, BorderLayout.EAST);
057:
058: contentPanel.setOpaque(false);
059: layout = new FormLayout("2dlu, pref:grow",
060: "3dlu, fill:10dlu, 2dlu");
061: contentPanel.setLayout(layout);
062:
063: add(contentPanel, BorderLayout.CENTER);
064:
065: //setBackground(new Color(236, 233, 216));
066: }
067:
068: public void setMainLeftComponent(JComponent c) {
069: contentPanel.add(c, new CellConstraints(2, 2));
070: }
071:
072: public void addRightComponent(JComponent c, int dialogUnits) {
073: layout.appendColumn(new ColumnSpec("2dlu"));
074: layout.appendColumn(new ColumnSpec(dialogUnits + "dlu"));
075:
076: layoutCoordinateX++;
077:
078: contentPanel.add(new SeparatorPanel(Color.GRAY, Color.WHITE),
079: new CellConstraints(layoutCoordinateX,
080: layoutCoordinateY));
081: layoutCoordinateX++;
082:
083: contentPanel.add(c, new CellConstraints(layoutCoordinateX,
084: layoutCoordinateY));
085: }
086:
087: public void addRightComponent(JComponent c) {
088: layout.appendColumn(new ColumnSpec("2dlu"));
089: layout.appendColumn(new ColumnSpec("default"));
090:
091: layoutCoordinateX++;
092:
093: contentPanel.add(new SeparatorPanel(Color.GRAY, Color.WHITE),
094: new CellConstraints(layoutCoordinateX,
095: layoutCoordinateY));
096: layoutCoordinateX++;
097:
098: contentPanel.add(c, new CellConstraints(layoutCoordinateX,
099: layoutCoordinateY));
100: }
101:
102: protected void paintComponent(Graphics g) {
103: super .paintComponent(g);
104:
105: int y = 0;
106: g.setColor(new Color(156, 154, 140));
107: g.drawLine(0, y, getWidth(), y);
108: y++;
109: g.setColor(new Color(196, 194, 183));
110: g.drawLine(0, y, getWidth(), y);
111: y++;
112: g.setColor(new Color(218, 215, 201));
113: g.drawLine(0, y, getWidth(), y);
114: y++;
115: g.setColor(new Color(233, 231, 217));
116: g.drawLine(0, y, getWidth(), y);
117:
118: y = getHeight() - 3;
119: g.setColor(new Color(233, 232, 218));
120: g.drawLine(0, y, getWidth(), y);
121: y++;
122: g.setColor(new Color(233, 231, 216));
123: g.drawLine(0, y, getWidth(), y);
124: y = getHeight() - 1;
125: g.setColor(new Color(221, 221, 220));
126: g.drawLine(0, y, getWidth(), y);
127:
128: }
129:
130: class SeparatorPanel extends JPanel {
131: private Color leftColor;
132:
133: private Color rightColor;
134:
135: SeparatorPanel(Color l, Color r) {
136: this .leftColor = l;
137: this .rightColor = r;
138: setOpaque(false);
139: }
140:
141: protected void paintComponent(Graphics g) {
142: g.setColor(leftColor);
143: g.drawLine(0, 0, 0, getHeight());
144: g.setColor(rightColor);
145: g.drawLine(1, 0, 1, getHeight());
146: }
147: }
148: }
|