001: /*
002: * PanelToolBar.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.toolbar;
023:
024: import java.awt.Dimension;
025: import java.awt.event.ActionListener;
026: import javax.swing.BorderFactory;
027: import javax.swing.BoxLayout;
028: import javax.swing.JButton;
029: import javax.swing.JComboBox;
030: import javax.swing.JLabel;
031: import javax.swing.JTextField;
032: import org.underworldlabs.swing.GUIUtils;
033: import org.underworldlabs.swing.RolloverButton;
034: import org.underworldlabs.swing.util.IconUtilities;
035:
036: /* ----------------------------------------------------------
037: * CVS NOTE: Changes to the CVS repository prior to the
038: * release of version 3.0.0beta1 has meant a
039: * resetting of CVS revision numbers.
040: * ----------------------------------------------------------
041: */
042:
043: /**
044: * Tab component tool bar panel.
045: *
046: * @author Takis Diakoumis
047: * @version $Revision: 1.5 $
048: * @date $Date: 2006/09/06 09:30:38 $
049: */
050: public class PanelToolBar extends AbstractToolBarPanel {
051:
052: /** Creates a new instance of PanelToolBar */
053: public PanelToolBar() {
054: setLayout(new BoxLayout(this , BoxLayout.X_AXIS));
055: setBorder(BorderFactory.createEmptyBorder(1, 2, 1, 1));
056: }
057:
058: public JButton addButton(ActionListener action,
059: String actionCommand, String icon, String toolTip,
060: boolean enabled) {
061: JButton button = new RolloverButton();
062:
063: if (icon != null) {
064: button.setIcon(IconUtilities.loadIcon(icon));
065: }
066:
067: button.setText(null);
068: button.setToolTipText(toolTip);
069: button.setActionCommand(actionCommand);
070: button.addActionListener(action);
071: button.setEnabled(enabled);
072: add(button);
073: return button;
074: }
075:
076: public JButton addButton(ActionListener action,
077: String actionCommand, String icon, String toolTip) {
078: return addButton(action, actionCommand, icon, toolTip, true);
079: }
080:
081: public void addSeparator() {
082: add(new PanelToolBarSeparator());
083: }
084:
085: public void addLabel(String text) {
086: add(new JLabel(text));
087: }
088:
089: public void addTextField(JTextField textField) {
090: add(textField);
091: }
092:
093: public void addComboBox(JComboBox comboBox) {
094: add(comboBox);
095: }
096:
097: public void addButton(JButton button) {
098: add(button);
099: }
100:
101: private class PanelToolBarSeparator extends JLabel {
102:
103: private int preferredWidth;
104:
105: public PanelToolBarSeparator() {
106: this (4);
107: }
108:
109: public PanelToolBarSeparator(int preferredWidth) {
110: this .preferredWidth = preferredWidth;
111: }
112:
113: public boolean isOpaque() {
114: return !GUIUtils.isDefaultLookAndFeel();
115: }
116:
117: public Dimension getPreferredSize() {
118: return new Dimension(preferredWidth, 1);
119: }
120:
121: public Dimension getMaximumSize() {
122: return getPreferredSize();
123: }
124:
125: public Dimension getMinimumSize() {
126: return getPreferredSize();
127: }
128:
129: }
130:
131: }
|