Last change
on this file since 1922 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
|
Rev | Line | |
---|
[298] | 1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
[1] | 2 | package org.openstreetmap.josm.gui;
|
---|
| 3 |
|
---|
[91] | 4 | import java.awt.event.MouseAdapter;
|
---|
| 5 | import java.awt.event.MouseEvent;
|
---|
[7] | 6 | import java.beans.PropertyChangeEvent;
|
---|
| 7 | import java.beans.PropertyChangeListener;
|
---|
| 8 |
|
---|
[1] | 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 | */
|
---|
[7] | 18 | public class IconToggleButton extends JToggleButton implements PropertyChangeListener {
|
---|
[1] | 19 |
|
---|
[1169] | 20 | public boolean groupbutton;
|
---|
[91] | 21 |
|
---|
[1169] | 22 | /**
|
---|
| 23 | * Construct the toggle button with the given action.
|
---|
| 24 | */
|
---|
| 25 | public IconToggleButton(Action action) {
|
---|
| 26 | super(action);
|
---|
| 27 | setText(null);
|
---|
[80] | 28 |
|
---|
[1169] | 29 | Object o = action.getValue(Action.SHORT_DESCRIPTION);
|
---|
| 30 | if (o != null)
|
---|
| 31 | setToolTipText(o.toString());
|
---|
[91] | 32 |
|
---|
[1169] | 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;
|
---|
[91] | 38 | }
|
---|
[1169] | 39 | });
|
---|
| 40 | }
|
---|
[7] | 41 |
|
---|
[1169] | 42 | public void propertyChange(PropertyChangeEvent evt) {
|
---|
| 43 | if (evt.getPropertyName().equals("active")) {
|
---|
| 44 | setSelected((Boolean)evt.getNewValue());
|
---|
| 45 | requestFocusInWindow();
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
[1] | 48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.