Skip to content

Package: ToolBarButton

ToolBarButton

nameinstructionbranchcomplexitylinemethod
ToolBarButton(ImageIcon, Action, Dimension)
M: 0 C: 29
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 10
100%
M: 0 C: 1
100%
ToolBarButton(String, Action)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 15
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: package networkconfigurator;
2:
3: import java.awt.Dimension;
4: import java.awt.Image;
5: import java.awt.Insets;
6:
7: import javax.swing.Action;
8: import javax.swing.ImageIcon;
9: import javax.swing.JButton;
10:
11: /**
12: * The button for the toolbar.
13: *
14: * @author admin
15: *
16: */
17: public class ToolBarButton extends JButton {
18:
19:         /**
20:          * Standardabstand eines ToolBarButtons.
21:          */
22:         private static final Insets MARGINS = new Insets(0, 0, 0, 0);
23:
24:         /**
25:          * Standardbreite eines ToolBarButtons.
26:          */
27:         private static final int DEFAULTWIDTH = 25;
28:
29:         /**
30:          * Standardgr��e eines ToolBarButtons. Normalerweise quadratisch
31:          */
32:         private static final Dimension DEFAUTSIZE = new Dimension(DEFAULTWIDTH, DEFAULTWIDTH);
33:
34:         /**
35:          * The Constructor.
36:          *
37:          * @param icon
38:          * the Icon.
39:          * @param a
40:          * the action behind the button.
41:          * @param size
42:          * the size of the button
43:          */
44:         public ToolBarButton(final ImageIcon icon, final Action a, final Dimension size) {
45:                 super.setAction(a);
46:                 final Image img = icon.getImage();
47:                 final Image newimg =
48:                                 img.getScaledInstance(DEFAULTWIDTH, DEFAULTWIDTH, java.awt.Image.SCALE_SMOOTH);
49:                 final ImageIcon rezsizedicon = new ImageIcon(newimg);
50:                 this.setIcon(rezsizedicon);
51:                 this.setPreferredSize(size);
52:                 this.setMargin(MARGINS);
53:         }
54:
55:         /**
56:          * the constructor.
57:          *
58:          * @param imageFile
59:          * the image for the button.
60:          * @param a
61:          * the action.
62:          */
63:         public ToolBarButton(final String imageFile, final Action a) {
64:                 this(new ImageIcon(imageFile), a, DEFAUTSIZE);
65:         }
66: }