KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > piratepete > dbpirate > ui > MainToolBar


1 package com.piratepete.dbpirate.ui;
2
3 import java.awt.Color JavaDoc;
4 import javax.swing.Action JavaDoc;
5 import javax.swing.BorderFactory JavaDoc;
6 import javax.swing.JButton JavaDoc;
7 import javax.swing.JToolBar JavaDoc;
8
9 /**
10  * MainToolBar Class
11  * Copyright (C) 2003 Jeremy Whitlock, David L. Whitehurst<p>
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.<p>
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.<p>
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.<p>
26  *
27  * <a HREF="http://www.piratepetesoftware.com">piratepetesoftware.com</a><br>
28  * <a HREF="mailto:dlwhitehurst@comcast.net">dlwhitehurst@comcast.net</a>
29  *
30  * @version 1.1.0
31  */

32
33 public class MainToolBar extends JToolBar JavaDoc{
34     //Instance Variables
35
//--------------------------------------------------------------------------
36
private JButton JavaDoc newFile,opnFile,sveFile,svaFile,prtFile,cutEdit,cpyEdit,
37     pstEdit,delEdit,redEdit,undEdit;
38     //--------------------------------------------------------------------------
39
//End Instance Variables
40

41     /** Creates a new instance of MainToolBar */
42     public MainToolBar(Action JavaDoc[] actions)
43     {
44         createButtons(actions);
45         
46         //Adds JButtons To JToolBar
47
//----------------------------------------------------------------------
48
this.add(newFile);
49 // this.add(opnFile);
50
// this.add(sveFile);
51
// this.add(svaFile);
52
// this.add(prtFile);
53
// this.addSeparator();
54
// this.add(cutEdit);
55
// this.add(cpyEdit);
56
// this.add(pstEdit);
57
// this.add(delEdit);
58
// this.add(redEdit);
59
// this.add(undEdit);
60
//----------------------------------------------------------------------
61
//End JToolBar
62

63         removeText();
64         removeMnemonic();
65         buildButtonBorders();
66         buildToolBarBorders();
67     }
68     
69     public void createButtons(Action JavaDoc[] actions)
70     {
71         newFile = new JButton JavaDoc(actions[0]);
72 // opnFile = new JButton(actions[1]);
73
// sveFile = new JButton(actions[4]);
74
// svaFile = new JButton(actions[5]);
75
// prtFile = new JButton(actions[6]);
76
// cutEdit = new JButton(actions[9]);
77
// cpyEdit = new JButton(actions[10]);
78
// pstEdit = new JButton(actions[11]);
79
// delEdit = new JButton(actions[13]);
80
// redEdit = new JButton(actions[8]);
81
// undEdit = new JButton(actions[7]);
82
}
83     
84     public void removeText()
85     {
86         newFile.setText("");
87 // opnFile.setText("");
88
// sveFile.setText("");
89
// svaFile.setText("");
90
// prtFile.setText("");
91
// cutEdit.setText("");
92
// cpyEdit.setText("");
93
// pstEdit.setText("");
94
// delEdit.setText("");
95
// redEdit.setText("");
96
// undEdit.setText("");
97
}
98     
99     public void removeMnemonic()
100     {
101         newFile.setMnemonic('\u0000');
102 // opnFile.setMnemonic('');
103
// sveFile.setMnemonic('');
104
// svaFile.setMnemonic('');
105
// prtFile.setMnemonic('');
106
// cutEdit.setMnemonic('');
107
// cpyEdit.setMnemonic('');
108
// pstEdit.setMnemonic('');
109
// delEdit.setMnemonic('');
110
// redEdit.setMnemonic('');
111
// undEdit.setMnemonic('');
112
}
113     
114     public void buildButtonBorders()
115     {
116         newFile.setFocusable(false);
117 // opnFile.setFocusable(false);
118
// sveFile.setFocusable(false);
119
// svaFile.setFocusable(false);
120
// prtFile.setFocusable(false);
121
// cutEdit.setFocusable(false);
122
// cpyEdit.setFocusable(false);
123
// pstEdit.setFocusable(false);
124
// delEdit.setFocusable(false);
125
// redEdit.setFocusable(false);
126
// undEdit.setFocusable(false);
127
}
128     
129     public void buildToolBarBorders()
130     {
131         this.setBorder(BorderFactory.createCompoundBorder(
132                 BorderFactory.createLineBorder(Color.DARK_GRAY),
133                 BorderFactory.createEmptyBorder(2,2,2,2)));
134         this.setRollover(true);
135     }
136     
137 }
138
Popular Tags