01: package jtaDiscRack.presentation.delements;
02:
03: import jtaDiscRack.*;
04:
05: import javax.swing.*;
06:
07: import java.awt.*;
08: import java.net.URL;
09:
10: /**
11: * The button.
12: *
13: * @author Sasa Bojanic
14: * @version 1.0
15: */
16: public class DButton extends JButton {
17:
18: /**
19: * Creates 'push' button with specified attributes.
20: *
21: * @param name the name to be written on the button.
22: * @param keyToIcon when an <i>imageSuffix</i> is added to
23: * this keyword, it presents the resource
24: * path keyword within property file. This
25: * resource represents an image file.
26: * @param d dimension of button.
27: */
28: public DButton(String name, String keyToIcon, Dimension d) {
29:
30: super (name);
31:
32: URL u = ResourceManager.getResource(keyToIcon + "Image");
33: if (u != null) {
34: setIcon(new ImageIcon(u));
35: }
36:
37: setVerticalTextPosition(AbstractButton.CENTER);
38: Insets i = getInsets();
39: Dimension di = new Dimension(d);
40: di.width = di.width + i.left + i.right;
41: di.height = di.height + i.top + i.bottom;
42:
43: setMinimumSize(new Dimension(di));
44: setMaximumSize(new Dimension(di));
45: setPreferredSize(new Dimension(di));
46:
47: }
48:
49: }
|