DButton.java :  » J2EE » enhydra » jtaDiscRack » presentation » delements » Java Open Source

Java Open Source » J2EE » enhydra 
enhydra » jtaDiscRack » presentation » delements » DButton.java
package jtaDiscRack.presentation.delements;

import jtaDiscRack.*;

import javax.swing.*;

import java.awt.*;
import java.net.URL;

/**
 * The button.
 *
 * @author Sasa Bojanic
 * @version 1.0
 */
public class DButton extends JButton {

   /**
   * Creates 'push' button with specified attributes.
   *
   * @param name      the name to be written on the button.
   * @param keyToIcon when an <i>imageSuffix</i> is added to
   *                  this keyword, it presents the resource
   *                  path keyword within property file. This
   *                  resource represents an image file.
   * @param d         dimension of button.
   */
   public DButton (String name,String keyToIcon,Dimension d) {

      super(name);

      URL u = ResourceManager.getResource(keyToIcon+"Image");
      if (u!=null) {
         setIcon(new ImageIcon(u));
      }

      setVerticalTextPosition(AbstractButton.CENTER);
      Insets i=getInsets();
      Dimension di=new Dimension(d);
      di.width=di.width+i.left+i.right;
      di.height=di.height+i.top+i.bottom;

      setMinimumSize(new Dimension(di));
      setMaximumSize(new Dimension(di));
      setPreferredSize(new Dimension(di));

   }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.