01: /*
02: * SQLeonardo :: java database frontend
03: * Copyright (C) 2004 nickyb@users.sourceforge.net
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License
07: * as published by the Free Software Foundation; either version 2
08: * of the License, or (at your option) any later version.
09: *
10: * This program is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: * GNU General Public License for more details.
14: *
15: * You should have received a copy of the GNU General Public License
16: * along with this program; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18: *
19: */
20:
21: package nickyb.sqleonardo.common.gui;
22:
23: import java.awt.Dimension;
24: import java.awt.event.ActionListener;
25:
26: import javax.swing.Action;
27: import javax.swing.JButton;
28:
29: public class CommandButton extends JButton {
30: public final static Dimension CUSTOM_DIMENSION = new Dimension(82,
31: 22);
32:
33: public CommandButton(Action a) {
34: super (a);
35: setAllSize();
36: }
37:
38: public CommandButton(String text) {
39: super (text);
40: setAllSize();
41: }
42:
43: public CommandButton(String text, ActionListener l) {
44: this (text);
45: addActionListener(l);
46: }
47:
48: public void setAllSize(Dimension allSize) {
49: Dimension size = this .getPreferredSize();
50:
51: size.height = allSize.height;
52: size.width = size.width > allSize.width ? size.width
53: : allSize.width;
54:
55: setPreferredSize(size);
56: setMaximumSize(size);
57: setMinimumSize(size);
58: }
59:
60: private void setAllSize() {
61: setAllSize(CUSTOM_DIMENSION);
62: }
63: }
|