Changeset 5493 in josm for trunk/src/org
- Timestamp:
- 2012-09-01T22:16:27+02:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AboutAction.java
r5194 r5493 20 20 import org.openstreetmap.josm.Main; 21 21 import org.openstreetmap.josm.data.Version; 22 import org.openstreetmap.josm.gui.util.GuiHelper; 22 23 import org.openstreetmap.josm.plugins.PluginHandler; 23 24 import org.openstreetmap.josm.tools.GBC; … … 43 44 44 45 public void actionPerformed(ActionEvent e) { 45 JTabbedPane about = new JTabbedPane();46 final JTabbedPane about = new JTabbedPane(); 46 47 47 48 Version version = Version.getInstance(); … … 91 92 about.addTab(tr("Plugins"), new JScrollPane(PluginHandler.getInfoPanel())); 92 93 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..."), 96 101 JOptionPane.INFORMATION_MESSAGE, ImageProvider.get("logo")); 97 102 } -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r5465 r5493 7 7 import java.awt.Color; 8 8 import java.awt.Component; 9 import java.awt.Dialog;10 9 import java.awt.Dimension; 11 10 import java.awt.FlowLayout; … … 13 12 import java.awt.GridBagConstraints; 14 13 import java.awt.GridBagLayout; 15 import java.awt.Window;16 14 import java.awt.event.ActionEvent; 17 15 import java.awt.event.ActionListener; 18 import java.awt.event.HierarchyEvent;19 import java.awt.event.HierarchyListener;20 16 import java.awt.event.MouseEvent; 21 17 import java.io.IOException; … … 42 38 import javax.swing.JTable; 43 39 import javax.swing.JToolBar; 44 import javax.swing.SwingUtilities;45 40 import javax.swing.event.ListSelectionEvent; 46 41 import javax.swing.event.ListSelectionListener; … … 67 62 import org.openstreetmap.josm.gui.preferences.PreferenceSettingFactory; 68 63 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 64 import org.openstreetmap.josm.gui.util.GuiHelper; 69 65 import org.openstreetmap.josm.tools.GBC; 70 66 import org.openstreetmap.josm.tools.ImageProvider; … … 431 427 public void actionPerformed(ActionEvent evt) { 432 428 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)); 446 430 int answer = JOptionPane.showConfirmDialog( 447 gui, p, 448 tr("Add Imagery URL"), 431 gui, p, tr("Add Imagery URL"), 449 432 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); 450 433 if (answer == JOptionPane.OK_OPTION) { -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r5484 r5493 6 6 import java.awt.Component; 7 7 import java.awt.Container; 8 import java.awt.Dialog; 9 import java.awt.Dimension; 8 10 import java.awt.Image; 9 11 import java.awt.Toolkit; 12 import java.awt.Window; 13 import java.awt.event.HierarchyEvent; 14 import java.awt.event.HierarchyListener; 10 15 import java.awt.image.FilteredImageSource; 11 16 import java.lang.reflect.InvocationTargetException; … … 104 109 return new ImageIcon(getDisabledImage(icon.getImage())); 105 110 } 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 } 106 140 }
Note:
See TracChangeset
for help on using the changeset viewer.