KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > discRack > presentation > delements > DButton


1 package discRack.presentation.delements;
2
3 import discRack.*;
4 import discRack.presentation.*;
5
6 import javax.swing.*;
7 import javax.swing.border.*;
8
9 import java.awt.*;
10 import java.net.URL JavaDoc;
11
12 /**
13  * The button.
14  *
15  * @author Sasa Bojanic
16  * @version 1.0
17  */

18 public class DButton extends JButton {
19
20    /**
21    * Creates 'push' button with specified attributes.
22    *
23    * @param name the name to be written on the button.
24    * @param keyToIcon when an <i>imageSuffix</i> is added to
25    * this keyword, it presents the resource
26    * path keyword within property file. This
27    * resource represents an image file.
28    * @param d dimension of button.
29    */

30    public DButton (String JavaDoc name,String JavaDoc keyToIcon,Dimension d) {
31
32       super(name);
33
34       URL JavaDoc u = ResourceManager.getResource(keyToIcon+"Image");
35       if (u!=null) {
36          setIcon(new ImageIcon(u));
37       }
38
39       setVerticalTextPosition(AbstractButton.CENTER);
40       Insets i=getInsets();
41       Dimension di=new Dimension(d);
42       di.width=di.width+i.left+i.right;
43       di.height=di.height+i.top+i.bottom;
44
45       setMinimumSize(new Dimension(di));
46       setMaximumSize(new Dimension(di));
47       setPreferredSize(new Dimension(di));
48
49    }
50
51 }
52
Popular Tags