01: package discRack.presentation.delements;
02:
03: import discRack.*;
04: import discRack.presentation.*;
05:
06: import javax.swing.*;
07: import javax.swing.border.*;
08:
09: import java.awt.*;
10: import java.net.URL;
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 name, String keyToIcon, Dimension d) {
31:
32: super (name);
33:
34: URL 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: }
|