[744] | 1 | package org.openstreetmap.josm.gui;
|
---|
| 2 |
|
---|
| 3 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
[758] | 4 | import static org.openstreetmap.josm.tools.I18n.marktr;
|
---|
[744] | 5 |
|
---|
| 6 | import java.awt.event.ActionListener;
|
---|
| 7 | import java.awt.Insets;
|
---|
| 8 | import javax.swing.Action;
|
---|
| 9 | import javax.swing.JButton;
|
---|
| 10 |
|
---|
| 11 | import org.openstreetmap.josm.tools.ImageProvider;
|
---|
| 12 |
|
---|
| 13 | public class SideButton extends JButton {
|
---|
| 14 | public SideButton(Action action)
|
---|
| 15 | {
|
---|
| 16 | super(action);
|
---|
| 17 | doStyle();
|
---|
| 18 | setText(null);
|
---|
| 19 | }
|
---|
| 20 | public SideButton(String imagename, String property, String tooltip, ActionListener actionListener)
|
---|
| 21 | {
|
---|
| 22 | super(ImageProvider.get("dialogs", imagename));
|
---|
| 23 | doStyle();
|
---|
| 24 | setActionCommand(imagename);
|
---|
| 25 | addActionListener(actionListener);
|
---|
| 26 | setToolTipText(tooltip);
|
---|
| 27 | }
|
---|
| 28 | public SideButton(String name, String imagename, String property, String tooltip, int mnemonic, ActionListener actionListener)
|
---|
| 29 | {
|
---|
| 30 | super(tr(name), ImageProvider.get("dialogs", imagename));
|
---|
| 31 | setMnemonic(mnemonic);
|
---|
| 32 | setup(name, property, tooltip, actionListener);
|
---|
| 33 | }
|
---|
| 34 | public SideButton(String name, String imagename, String property, String tooltip, ActionListener actionListener)
|
---|
| 35 | {
|
---|
| 36 | super(tr(name), ImageProvider.get("dialogs", imagename));
|
---|
| 37 | setup(name, property, tooltip, actionListener);
|
---|
| 38 | }
|
---|
| 39 | private void setup(String name, String property, String tooltip, ActionListener actionListener)
|
---|
| 40 | {
|
---|
| 41 | doStyle();
|
---|
| 42 | setActionCommand(name);
|
---|
| 43 | addActionListener(actionListener);
|
---|
| 44 | setToolTipText(tooltip);
|
---|
| 45 | putClientProperty("help", "Dialog/"+property+"/"+name);
|
---|
| 46 | }
|
---|
| 47 | private void doStyle()
|
---|
| 48 | {
|
---|
| 49 | setMargin(new Insets(1,1,1,1));
|
---|
| 50 | setIconTextGap(2);
|
---|
| 51 | }
|
---|
| 52 | }
|
---|