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) 2006.
14: //
15: //All Rights Reserved.
16:
17: package org.columba.core.gui.toolbar;
18:
19: import java.awt.Insets;
20:
21: import javax.swing.Action;
22: import javax.swing.Icon;
23: import javax.swing.JButton;
24:
25: /**
26: * ToolBar button.
27: *
28: * @author Frederik Dietz
29: */
30: @SuppressWarnings("serial")
31: public class ToolBarButton extends JButton {
32:
33: public ToolBarButton(String text, Icon icon) {
34: super (text, icon);
35:
36: initButton();
37: }
38:
39: public ToolBarButton() {
40: super ();
41: initButton();
42: }
43:
44: public ToolBarButton(Action action) {
45: super (action);
46:
47: initButton();
48: }
49:
50: private void initButton() {
51: setRolloverEnabled(true);
52: setRequestFocusEnabled(false);
53: setMargin(new Insets(1, 1, 1, 1));
54: putClientProperty("JToolBar.isRollover", Boolean.TRUE);
55: }
56:
57: public boolean isFocusTraversable() {
58: return isRequestFocusEnabled();
59: }
60:
61: /**
62: * @see javax.swing.JButton#updateUI()
63: */
64: public void updateUI() {
65: super .updateUI();
66:
67: setRolloverEnabled(true);
68: putClientProperty("JToolBar.isRollover", Boolean.TRUE);
69: }
70: }
|