01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
10: //The Original Code is "The Columba Project"
11: //
12: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16: package org.columba.core.gui.toolbar;
17:
18: import java.awt.FlowLayout;
19:
20: import javax.swing.JButton;
21: import javax.swing.JSeparator;
22: import javax.swing.JToolBar;
23:
24: import org.columba.core.gui.action.AbstractColumbaAction;
25:
26: /**
27: * Extendable toolbar.
28: *
29: * @author fdietz
30: */
31:
32: public class ExtendableToolBar extends JToolBar {
33:
34: int insertPosition = 0;
35:
36: public ExtendableToolBar() {
37: super ();
38:
39: setRollover(true);
40: // setFloatable(true);
41: }
42:
43: public void add(AbstractColumbaAction action) {
44: JButton button = ToolBarButtonFactory.createButton(action);
45:
46: add(button, insertPosition);
47:
48: insertPosition++;
49: }
50:
51: public void insert(AbstractColumbaAction action, int position) {
52: JButton button = ToolBarButtonFactory.createButton(action);
53:
54: add(button, position);
55:
56: if (position >= insertPosition)
57: insertPosition++;
58: }
59:
60: /**
61: * @see javax.swing.JToolBar#addSeparator()
62: */
63: public void addSeparator() {
64: JToolBar.Separator s = new JToolBar.Separator(null);
65: if (getOrientation() == VERTICAL) {
66: s.setOrientation(JSeparator.HORIZONTAL);
67: } else {
68: s.setOrientation(JSeparator.VERTICAL);
69: }
70:
71: add(s, insertPosition);
72:
73: insertPosition++;
74: }
75:
76: /**
77: * @see javax.swing.JToolBar#updateUI()
78: */
79: public void updateUI() {
80: super .updateUI();
81: setRollover(true);
82: }
83:
84: }
|