Changeset 5493 in josm


Ignore:
Timestamp:
2012-09-01T22:16:27+02:00 (12 years ago)
Author:
Don-vip
Message:

see #8011 - Small improvements in About dialog

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/README

    r5341 r5493  
    1515How to get Java Runtime Environment
    1616-----------------------------------
    17 You need JRE Version 1.6 (also called Java6), or later.
     17You need JRE Version 1.6 (also called Java 6), or later.
    1818
    19 Microsoft Windows users should visit
    20 http://www.oracle.com/technetwork/java/index.html
    21 and download the latest Java6 executable for Windows systems.
     19Microsoft Windows users should visit http://www.java.com
     20and download the latest Java executable for Windows systems.
    2221
    2322Linux users should visit http://www.oracle.com/technetwork/java/index.html
     
    3938not the bin).
    4039
    41 MacOS users just click on the .jar file icon.
     40MacOS X users just click on the .jar file icon.
    4241
    4342=============================================================================
  • trunk/src/org/openstreetmap/josm/actions/AboutAction.java

    r5194 r5493  
    2020import org.openstreetmap.josm.Main;
    2121import org.openstreetmap.josm.data.Version;
     22import org.openstreetmap.josm.gui.util.GuiHelper;
    2223import org.openstreetmap.josm.plugins.PluginHandler;
    2324import org.openstreetmap.josm.tools.GBC;
     
    4344
    4445    public void actionPerformed(ActionEvent e) {
    45         JTabbedPane about = new JTabbedPane();
     46        final JTabbedPane about = new JTabbedPane();
    4647
    4748        Version version = Version.getInstance();
     
    9192        about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel()));
    9293
    93         about.setPreferredSize(new Dimension(500,300));
    94 
    95         JOptionPane.showMessageDialog(Main.parent, about, tr("About JOSM..."),
     94        // Intermediate panel to allow proper optionPane resizing
     95        JPanel panel = new JPanel(new GridBagLayout());
     96        panel.setPreferredSize(new Dimension(600, 300));
     97        panel.add(about, GBC.std().fill());
     98       
     99        GuiHelper.prepareResizeableOptionPane(panel, panel.getPreferredSize());
     100        JOptionPane.showMessageDialog(Main.parent, panel, tr("About JOSM..."),
    96101                JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo"));
    97102    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java

    r5465 r5493  
    77import java.awt.Color;
    88import java.awt.Component;
    9 import java.awt.Dialog;
    109import java.awt.Dimension;
    1110import java.awt.FlowLayout;
     
    1312import java.awt.GridBagConstraints;
    1413import java.awt.GridBagLayout;
    15 import java.awt.Window;
    1614import java.awt.event.ActionEvent;
    1715import java.awt.event.ActionListener;
    18 import java.awt.event.HierarchyEvent;
    19 import java.awt.event.HierarchyListener;
    2016import java.awt.event.MouseEvent;
    2117import java.io.IOException;
     
    4238import javax.swing.JTable;
    4339import javax.swing.JToolBar;
    44 import javax.swing.SwingUtilities;
    4540import javax.swing.event.ListSelectionEvent;
    4641import javax.swing.event.ListSelectionListener;
     
    6762import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory;
    6863import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     64import org.openstreetmap.josm.gui.util.GuiHelper;
    6965import org.openstreetmap.josm.tools.GBC;
    7066import org.openstreetmap.josm.tools.ImageProvider;
     
    431427            public void actionPerformed(ActionEvent evt) {
    432428                final AddWMSLayerPanel p = new AddWMSLayerPanel();
    433                 // This code snippet allows to resize the JOptionPane (fix #6090)
    434                 p.addHierarchyListener(new HierarchyListener() {
    435                     public void hierarchyChanged(HierarchyEvent e) {
    436                         Window window = SwingUtilities.getWindowAncestor(p);
    437                         if (window instanceof Dialog) {
    438                             Dialog dialog = (Dialog)window;
    439                             if (!dialog.isResizable()) {
    440                                 dialog.setResizable(true);
    441                                 dialog.setMinimumSize(new Dimension(250, 350));
    442                             }
    443                         }
    444                     }
    445                 });
     429                GuiHelper.prepareResizeableOptionPane(p, new Dimension(250, 350));
    446430                int answer = JOptionPane.showConfirmDialog(
    447                         gui, p,
    448                         tr("Add Imagery URL"),
     431                        gui, p, tr("Add Imagery URL"),
    449432                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    450433                if (answer == JOptionPane.OK_OPTION) {
  • trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java

    r5484 r5493  
    66import java.awt.Component;
    77import java.awt.Container;
     8import java.awt.Dialog;
     9import java.awt.Dimension;
    810import java.awt.Image;
    911import java.awt.Toolkit;
     12import java.awt.Window;
     13import java.awt.event.HierarchyEvent;
     14import java.awt.event.HierarchyListener;
    1015import java.awt.image.FilteredImageSource;
    1116import java.lang.reflect.InvocationTargetException;
     
    104109        return new ImageIcon(getDisabledImage(icon.getImage()));
    105110    }
     111   
     112    /**
     113     * Attaches a {@code HierarchyListener} to the specified {@code Component} that
     114     * will set its parent dialog resizeable. Use it before a call to JOptionPane#showXXXXDialog
     115     * to make it resizeable.
     116     * @param pane The component that will be displayed
     117     * @param minDimension The minimum dimension that will be set for the dialog. Ignored if null
     118     * @return {@code pane}
     119     * @since 5493
     120     */
     121    public static final Component prepareResizeableOptionPane(final Component pane, final Dimension minDimension) {
     122        if (pane != null) {
     123            pane.addHierarchyListener(new HierarchyListener() {
     124                public void hierarchyChanged(HierarchyEvent e) {
     125                    Window window = SwingUtilities.getWindowAncestor(pane);
     126                    if (window instanceof Dialog) {
     127                        Dialog dialog = (Dialog)window;
     128                        if (!dialog.isResizable()) {
     129                            dialog.setResizable(true);
     130                            if (minDimension != null) {
     131                                dialog.setMinimumSize(minDimension);
     132                            }
     133                        }
     134                    }
     135                }
     136            });
     137        }
     138        return pane;
     139    }
    106140}
Note: See TracChangeset for help on using the changeset viewer.