KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > core > gui > toolbar > ToolBarButton


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
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 JavaDoc;
20
21 import javax.swing.Action JavaDoc;
22 import javax.swing.Icon JavaDoc;
23 import javax.swing.JButton JavaDoc;
24
25 /**
26  * ToolBar button.
27  *
28  * @author Frederik Dietz
29  */

30 @SuppressWarnings JavaDoc("serial")
31 public class ToolBarButton extends JButton JavaDoc {
32
33     public ToolBarButton(String JavaDoc text, Icon JavaDoc icon) {
34         super(text, icon);
35         
36         initButton();
37     }
38     
39     public ToolBarButton() {
40         super();
41         initButton();
42     }
43
44     
45     public ToolBarButton(Action JavaDoc action) {
46         super(action);
47
48         initButton();
49     }
50
51     private void initButton() {
52         setRolloverEnabled(true);
53         setRequestFocusEnabled(false);
54         setMargin(new Insets JavaDoc(1, 1, 1, 1));
55         putClientProperty("JToolBar.isRollover", Boolean.TRUE);
56     }
57
58     public boolean isFocusTraversable() {
59         return isRequestFocusEnabled();
60     }
61
62     /**
63      * @see javax.swing.JButton#updateUI()
64      */

65     public void updateUI() {
66         super.updateUI();
67
68         setRolloverEnabled(true);
69         putClientProperty("JToolBar.isRollover", Boolean.TRUE);
70     }
71 }
72
Popular Tags