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

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