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