jTracer  1.03
Stack trace visualization tool
Button.java
Go to the documentation of this file.
1 
7 package org.libcsdbg.jtracer;
8 
9 import java.awt.event.MouseEvent;
10 import java.awt.event.MouseListener;
11 import java.awt.event.ActionListener;
12 import java.awt.Font;
13 import java.awt.Color;
14 
15 import javax.swing.JButton;
16 
20 public class Button extends JButton implements MouseListener
21 {
23  private static final long serialVersionUID = 0x00;
24 
25 
35  Button(String nm, String cmd, ActionListener handler)
36  {
37  super();
38  Registry conf = Registry.getCurrent();
39  setIcon(conf.loadIcon(nm));
40 
41  Integer delay = (Integer) conf.get("component", "click-delay");
42  if (delay != null)
43  setMultiClickThreshhold(delay);
44 
45  setToolTipText(cmd);
46  setContentAreaFilled(false);
47  setBorderPainted(false);
48  setRolloverEnabled(false);
49 
50  setActionCommand(cmd);
51  addActionListener(handler);
52  addMouseListener(this);
53  }
54 
55 
69  Button(String nm, String text, int htpos, int vtpos, ActionListener handler)
70  {
71  super(text);
72  Registry conf = Registry.getCurrent();
73  setIcon(conf.loadIcon(nm));
74 
75  setFont((Font) conf.get("component", "font"));
76  setForeground((Color) conf.get("component", "fgcolor"));
77 
78  Integer delay = (Integer) conf.get("component", "click-delay");
79  if (delay != null)
80  setMultiClickThreshhold(delay);
81 
82  setHorizontalTextPosition(htpos);
83  setVerticalTextPosition(vtpos);
84  setContentAreaFilled(false);
85  setBorderPainted(false);
86  setRolloverEnabled(false);
87 
88  setActionCommand(text);
89  addActionListener(handler);
90  addMouseListener(this);
91  }
92 
93 
101  Button(String text, ActionListener handler)
102  {
103  super(text);
104  Registry conf = Registry.getCurrent();
105 
106  setFont((Font) conf.get("component", "font"));
107  setForeground((Color) conf.get("component", "fgcolor"));
108 
109  Integer delay = (Integer) conf.get("component", "click-delay");
110  if (delay != null)
111  setMultiClickThreshhold(delay);
112 
113  setContentAreaFilled(false);
114  setActionCommand(text);
115  addActionListener(handler);
116  }
117 
118 
124  public void setEnabled(boolean how)
125  {
126  /* If it is an icon button, hide its border if it gets disabled */
127  if (!how && getIcon() != null)
128  setBorderPainted(false);
129 
130  super.setEnabled(how);
131  }
132 
133 
139  public void mouseEntered(MouseEvent event)
140  {
141  try {
142  if (isEnabled())
143  setBorderPainted(true);
144  }
145 
146  catch (Throwable t) {
147  Registry.debug(t);
148  }
149  }
150 
151 
157  public void mouseExited(MouseEvent event)
158  {
159  try {
160  setBorderPainted(false);
161  }
162 
163  catch (Throwable t) {
164  Registry.debug(t);
165  }
166  }
167 
168 
174  public void mousePressed(MouseEvent event)
175  {
176  }
177 
178 
184  public void mouseReleased(MouseEvent event)
185  {
186  }
187 
188 
194  public void mouseClicked(MouseEvent event)
195  {
196  }
197 }
198 
void mouseEntered(MouseEvent event)
Handler for events fired when the mouse enters the button area.
Definition: Button.java:139
Multitype button with configurable styles and behaviour.
Definition: Button.java:20
Object get(String section, String key)
Get an entry.
Definition: Registry.java:151
Configuration registry.
Definition: Registry.java:41
void mousePressed(MouseEvent event)
Handler for events fired when a mouse button is pressed.
Definition: Button.java:174
ImageIcon loadIcon(String nm)
Load an icon from the current theme.
Definition: Registry.java:220
void mouseClicked(MouseEvent event)
Handler for events fired when a mouse button is clicked.
Definition: Button.java:194
void setEnabled(boolean how)
Enable or disable.
Definition: Button.java:124
void mouseExited(MouseEvent event)
Handler for events fired when the mouse exits the button area.
Definition: Button.java:157
static final long serialVersionUID
Class version.
Definition: Button.java:23
void mouseReleased(MouseEvent event)
Handler for events fired when a mouse button is released.
Definition: Button.java:184