KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > xml > XMLButton


1 /* XMLButton.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11
12 package org.enhydra.jawe.xml;
13
14 import javax.swing.*;
15 import javax.swing.border.*;
16
17 import java.awt.*;
18 import java.net.URL JavaDoc;
19
20 /**
21 * An implementation of 'push' button that depending on
22 * parameters passed during creation, sets proper button
23 * name, icon and dimension.
24 */

25 public class XMLButton extends JButton {
26
27    /**
28    * Creates 'push' button with specified attributes.
29    *
30    * @param name the name to be written on the button.
31    * @param keyToIcon when an <i>imageSuffix</i> is added to
32    * this keyword, it presents the resource
33    * path keyword within property file. This
34    * resource represents an image file.
35    * @param d dimension of button.
36    */

37    public XMLButton (String JavaDoc name,String JavaDoc keyToIcon,Dimension d) {
38
39       super(name);
40
41       URL JavaDoc u = XMLUtil.getResource(keyToIcon+"Image");
42       if (u!=null) {
43          setIcon(new ImageIcon(u));
44       }
45
46       setVerticalTextPosition(AbstractButton.CENTER);
47       Insets i=getInsets();
48       Dimension di=new Dimension(d);
49       di.width=di.width+i.left+i.right;
50       di.height=di.height+i.top+i.bottom;
51
52       setMinimumSize(new Dimension(di));
53       setMaximumSize(new Dimension(di));
54       setPreferredSize(new Dimension(di));
55
56    }
57
58 }
59
60 /* End of XMLButton.java */
61
Popular Tags