01: package com.opensymphony.workflow.designer.swing;
02:
03: import java.awt.*;
04: import javax.swing.*;
05:
06: import com.opensymphony.workflow.designer.ResourceManager;
07:
08: public class FixedButton extends JButton {
09: private final int length;
10: private final Component attachedComponent;
11:
12: private FixedButton(int i, Component c) {
13: super (ResourceManager.getIcon("ellipsis"));
14: length = i;
15: attachedComponent = c;
16: setMargin(new Insets(0, 0, 0, 0));
17: setDefaultCapable(false);
18: setFocusable(false);
19: }
20:
21: public FixedButton(int i) {
22: this (i, null);
23: if (i <= 0)
24: throw new IllegalArgumentException("wrong size: " + i);
25: else
26: return;
27: }
28:
29: public FixedButton(JComponent jcomponent) {
30: this (-1, jcomponent);
31: if (jcomponent == null)
32: throw new IllegalArgumentException(
33: "component cannot be null");
34: else
35: return;
36: }
37:
38: public Dimension getMinimumSize() {
39: return getPreferredSize();
40: }
41:
42: public Dimension getMaximumSize() {
43: return getPreferredSize();
44: }
45:
46: public Dimension getPreferredSize() {
47: if (attachedComponent != null) {
48: int i = attachedComponent.getPreferredSize().height;
49: return new Dimension(i, i);
50: }
51: return new Dimension(length, length);
52: }
53:
54: public Component getAttachedComponent() {
55: return attachedComponent;
56: }
57: }
|