1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.devaki.nextobjects.ui.components;
21 import java.awt.Insets;
22 import java.awt.event.MouseAdapter;
23 import java.awt.event.MouseEvent;
24 import javax.swing.ImageIcon;
25 import javax.swing.JToggleButton;
26 import org.devaki.nextobjects.NextObjects;
27 /***
28 * This class overwrite the 'JToggleButton' component
29 * @param icon icon
30 * @param tooltipText tooltip text
31 * @param statusBarText status bar text
32 * @param isSelected pre select
33 */
34 public class CustomToggleButton extends JToggleButton
35 {
36 /***
37 * Create a 'CustomToggleButton' object
38 * @param icon Image icon
39 * @param tooltipText Tootip text
40 * @param statusBarText the status bar text
41 * @param isEnabled is enabled
42 * @param isSelected is selected
43 */
44 public CustomToggleButton(
45 final ImageIcon icon,
46 final String tooltipText,
47 final String statusBarText,
48 final boolean isEnabled,
49 final boolean isSelected)
50 {
51 super(icon, isSelected);
52
53 if (tooltipText.length() != 0)
54 {
55 this.setToolTipText(tooltipText);
56 }
57
58 this.setEnabled(isEnabled);
59
60 this.setMargin(new Insets(0, 0, 0, 0));
61
62
63 this.addMouseListener(new MouseAdapter()
64 {
65 public final void mouseEntered(final MouseEvent e)
66 {
67 NextObjects.setStatusBarText(statusBarText);
68 }
69 public final void mouseExited(final MouseEvent e)
70 {
71 NextObjects.setStatusBarText(" ");
72 }
73 });
74 }
75 }