File Source: ImageToggleButton.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.components.ImageToggleButton__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.addons.ui_swing.components;
24
25 import java.awt.Dimension;
26 import java.awt.Insets;
27
28 import javax.swing.BorderFactory;
29 import javax.swing.Icon;
30 import javax.swing.JToggleButton;
31
32 /**
33 * Image toggle button.
34 */
35 public class ImageToggleButton extends JToggleButton {
36
37 /**
38 * A version number for this class. It should be changed whenever the class
39 * structure is changed (or anything else that would prevent serialized
40 * objects being unserialized with the new class).
41 */
42 private static final long serialVersionUID = 2;
43
44 /**
45 * Creates a new instance of ImageToggleButton.
46 *
47 * @param actionCommand Action command for the button
48 * @param icon Normal icon for the button
49 */
50 public ImageToggleButton(final String actionCommand, final Icon icon) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.components.ImageToggleButton(String, Icon)
*/
51 this(actionCommand, icon, icon);
52 }
53
54 /**
55 * Creates a new instance of ImageToggleButton.
56 *
57 * @param actionCommand Action command for the button
58 * @param icon Normal icon for the button
59 * @param rolloverIcon Rollover icon for the button
60 */
61 public ImageToggleButton(final String actionCommand, final Icon icon,
62 final Icon rolloverIcon) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.components.ImageToggleButton(String, Icon, Icon)
*/
63 this(actionCommand, icon, rolloverIcon, rolloverIcon);
64 }
65
66 /**
67 * Creates a new instance of ImageToggleButton.
68 *
69 * @param actionCommand Action command for the button
70 * @param icon Normal icon for the button
71 * @param rolloverIcon Rollover icon for the button
72 * @param pressedIcon Pressed icon for the button
73 */
74 public ImageToggleButton(final String actionCommand, final Icon icon,
75 final Icon rolloverIcon, final Icon pressedIcon) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.components.ImageToggleButton(String, Icon, Icon, Icon)
*/
76 super();
77
78 setIcon(icon);
79 setRolloverIcon(rolloverIcon);
80 setPressedIcon(pressedIcon);
81 setSelectedIcon(pressedIcon);
82 setContentAreaFilled(false);
83 setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
84 setMargin(new Insets(0, 0, 0, 0));
85 setPreferredSize(new Dimension(16, 0));
86 setActionCommand(actionCommand);
87 }
88
89 /**
90 * Sets all the image buttons icons
91 *
92 * @param icon New icon
93 */
94 public void setIcons(final Icon icon) {
/*
P/P * Method: void setIcons(Icon)
*/
95 setIcon(icon);
96 setRolloverIcon(icon);
97 setPressedIcon(icon);
98 }
99 }
SofCheck Inspector Build Version : 2.17854
| ImageToggleButton.java |
2009-Jun-25 01:54:24 |
| ImageToggleButton.class |
2009-Sep-02 17:04:15 |