01: /*
02: * Copyright 2005 Paul Hinds
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.tp23.antinstaller.renderer.swing;
17:
18: import java.awt.Dimension;
19: import java.awt.Insets;
20:
21: import javax.swing.Action;
22: import javax.swing.Icon;
23: import javax.swing.JButton;
24:
25: /**
26: * A JButton with altered prefered size to facilitate fixing the width
27: * but still using a GridBagLayout.
28: * Insets are set to zero to maximise the available space for the text in the button.
29: * @author Paul Hinds
30: * @version $Id: AIButton.java,v 1.2 2006/12/09 15:26:09 teknopaul Exp $
31: */
32: public class AIButton extends JButton {
33:
34: public AIButton() {
35: super ();
36: setMargin(new Insets(0, 0, 0, 0));
37: }
38:
39: public AIButton(String text) {
40: super (text);
41: setMargin(new Insets(0, 0, 0, 0));
42: }
43:
44: public AIButton(Action a) {
45: super (a);
46: setMargin(new Insets(0, 0, 0, 0));
47: }
48:
49: public AIButton(Icon icon) {
50: super (icon);
51: setMargin(new Insets(0, 0, 0, 0));
52: }
53:
54: public AIButton(String text, Icon icon) {
55: super (text, icon);
56: setMargin(new Insets(0, 0, 0, 0));
57: }
58:
59: private Dimension prefSize = new Dimension(
60: SizeConstants.BUTTON_WIDTH, SizeConstants.FIELD_HEIGHT);
61:
62: public Dimension getMinimumSize() {
63: return prefSize;
64: }
65:
66: public Dimension getPreferredSize() {
67: return prefSize;
68: }
69:
70: public void setOverflow(Dimension prefSize) {
71: this .prefSize = prefSize;
72: }
73:
74: public Dimension getMaximumSize() {
75: return prefSize;
76: }
77:
78: }
|