Last change
on this file since 2001 was 1169, checked in by stoecker, 15 years ago |
removed usage of tab stops
|
-
Property svn:eol-style
set to
native
|
File size:
1.3 KB
|
Line | |
---|
1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
2 | package org.openstreetmap.josm.gui;
|
---|
3 |
|
---|
4 | import java.awt.event.MouseAdapter;
|
---|
5 | import java.awt.event.MouseEvent;
|
---|
6 | import java.beans.PropertyChangeEvent;
|
---|
7 | import java.beans.PropertyChangeListener;
|
---|
8 |
|
---|
9 | import javax.swing.Action;
|
---|
10 | import javax.swing.JToggleButton;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Just a toggle button, with smaller border and icon only to display in
|
---|
14 | * MapFrame toolbars.
|
---|
15 | *
|
---|
16 | * @author imi
|
---|
17 | */
|
---|
18 | public class IconToggleButton extends JToggleButton implements PropertyChangeListener {
|
---|
19 |
|
---|
20 | public boolean groupbutton;
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Construct the toggle button with the given action.
|
---|
24 | */
|
---|
25 | public IconToggleButton(Action action) {
|
---|
26 | super(action);
|
---|
27 | setText(null);
|
---|
28 |
|
---|
29 | Object o = action.getValue(Action.SHORT_DESCRIPTION);
|
---|
30 | if (o != null)
|
---|
31 | setToolTipText(o.toString());
|
---|
32 |
|
---|
33 | action.addPropertyChangeListener(this);
|
---|
34 |
|
---|
35 | addMouseListener(new MouseAdapter(){
|
---|
36 | @Override public void mousePressed(MouseEvent e) {
|
---|
37 | groupbutton = e.getX() > getWidth()/2 && e.getY() > getHeight()/2;
|
---|
38 | }
|
---|
39 | });
|
---|
40 | }
|
---|
41 |
|
---|
42 | public void propertyChange(PropertyChangeEvent evt) {
|
---|
43 | if (evt.getPropertyName().equals("active")) {
|
---|
44 | setSelected((Boolean)evt.getNewValue());
|
---|
45 | requestFocusInWindow();
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.