01: /*
02: * SSHTools - Java SSH2 API
03: *
04: * Copyright (C) 2002-2003 Lee David Painter and Contributors.
05: *
06: * Contributions made by:
07: *
08: * Brett Smith
09: * Richard Pernavas
10: * Erwin Bolwidt
11: *
12: * This program is free software; you can redistribute it and/or
13: * modify it under the terms of the GNU General Public License
14: * as published by the Free Software Foundation; either version 2
15: * of the License, or (at your option) any later version.
16: *
17: * This program is distributed in the hope that it will be useful,
18: * but WITHOUT ANY WARRANTY; without even the implied warranty of
19: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: * GNU General Public License for more details.
21: *
22: * You should have received a copy of the GNU General Public License
23: * along with this program; if not, write to the Free Software
24: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25: */
26: package com.sshtools.common.ui;
27:
28: import java.awt.*;
29:
30: import javax.swing.*;
31:
32: public class FolderBar extends JPanel {
33: // Private instance variables
34: private JLabel textLabel;
35:
36: // Private instance variables
37: private JLabel iconLabel;
38: private Action action;
39:
40: public FolderBar() {
41: this (null, null);
42: }
43:
44: public FolderBar(String text) {
45: this (text, null);
46: }
47:
48: public FolderBar(String text, Icon icon) {
49: super (new BorderLayout());
50: setOpaque(true);
51: setBackground(getBackground().darker());
52: add(textLabel = new JLabel(), BorderLayout.CENTER);
53: add(iconLabel = new JLabel(), BorderLayout.WEST);
54: iconLabel.setFont(iconLabel.getFont().deriveFont(Font.BOLD));
55: textLabel.setVerticalAlignment(JLabel.CENTER);
56: textLabel.setVerticalTextPosition(JLabel.BOTTOM);
57: textLabel.setForeground(Color.lightGray);
58: iconLabel.setVerticalAlignment(JLabel.CENTER);
59: setIcon(icon);
60: setText(text);
61: }
62:
63: public Action getAction() {
64: return action;
65: }
66:
67: public void setAction(Action action) {
68: this .action = action;
69: setIcon((Icon) action.getValue(Action.SMALL_ICON));
70: setText((String) action.getValue(Action.NAME));
71: }
72:
73: public void setText(String text) {
74: textLabel.setText(text);
75: }
76:
77: public void setIcon(Icon icon) {
78: iconLabel.setIcon(icon);
79: }
80: }
|