source: josm/src/org/openstreetmap/josm/actions/PreferencesAction.java@ 178

Last change on this file since 178 was 178, checked in by imi, 17 years ago
  • fixed display of tooltip shortcuts
  • added icon=... to annotation presets
  • added support for putting annotation presets in the toolbar
File size: 1.5 KB
Line 
1package org.openstreetmap.josm.actions;
2
3import static org.openstreetmap.josm.tools.I18n.tr;
4
5import java.awt.GridBagLayout;
6import java.awt.event.ActionEvent;
7import java.awt.event.KeyEvent;
8
9import javax.swing.JDialog;
10import javax.swing.JOptionPane;
11import javax.swing.JPanel;
12
13import org.openstreetmap.josm.Main;
14import org.openstreetmap.josm.gui.preferences.PreferenceDialog;
15import org.openstreetmap.josm.tools.GBC;
16
17/**
18 * Open the Preferences dialog.
19 *
20 * @author imi
21 */
22public class PreferencesAction extends JosmAction {
23
24 /**
25 * Create the preference action with "&Preferences" as label.
26 */
27 public PreferencesAction() {
28 super(tr("Preferences"), "preference", tr("Open a preferences page for global settings."), KeyEvent.VK_F12, 0, true);
29 }
30
31 /**
32 * Launch the preferences dialog.
33 */
34 public void actionPerformed(ActionEvent e) {
35 PreferenceDialog prefDlg = new PreferenceDialog();
36 JPanel prefPanel = new JPanel(new GridBagLayout());
37 prefPanel.add(prefDlg, GBC.eol().fill(GBC.BOTH));
38
39 JOptionPane pane = new JOptionPane(prefPanel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
40 JDialog dlg = pane.createDialog(Main.parent, tr("Preferences"));
41
42 if (dlg.getWidth() > 600)
43 dlg.setSize(600, dlg.getHeight());
44 if (dlg.getHeight() > 600)
45 dlg.setSize(dlg.getWidth(),600);
46
47 dlg.setVisible(true);
48 if (pane.getValue() instanceof Integer && (Integer)pane.getValue() == JOptionPane.OK_OPTION)
49 prefDlg.ok();
50 }
51}
Note: See TracBrowser for help on using the repository browser.