Changeset 4524 in josm


Ignore:
Timestamp:
2011-10-19T01:49:40+02:00 (13 years ago)
Author:
Don-vip
Message:

fix #6090 - Resize-Feature for the WMS-Property-Dialog

Location:
trunk/src/org/openstreetmap/josm/gui/preferences
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/AddWMSLayerPanel.java

    r4472 r4524  
    77import java.awt.Component;
    88import java.awt.Cursor;
     9import java.awt.Dimension;
    910import java.awt.GridBagConstraints;
    1011import java.awt.GridBagLayout;
     
    2728import java.util.List;
    2829import java.util.Set;
    29 
    3030import java.util.regex.Pattern;
     31
    3132import javax.swing.JButton;
    32 import javax.swing.JFrame;
    3333import javax.swing.JLabel;
    3434import javax.swing.JOptionPane;
     
    8484
    8585    public AddWMSLayerPanel() {
    86         JPanel imageryAddPanel = new JPanel(new GridBagLayout());
    87         imageryAddPanel.add(new JLabel(tr("Menu Name")), GBC.std().insets(0,0,5,0));
     86        super(new GridBagLayout());
     87        add(new JLabel(tr("Menu Name")), GBC.std().insets(0,0,5,0));
    8888        menuName = new JTextField(40);
    8989        menuName.setText(tr("Unnamed Imagery Layer"));
    90         imageryAddPanel.add(menuName, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     90        add(menuName, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
    9191
    9292        final JTabbedPane tabbedPane = new JTabbedPane();
     
    9494        final JPanel wmsFetchPanel = new JPanel(new GridBagLayout());
    9595        tabbedPane.addTab(tr("WMS"), wmsFetchPanel);
    96         imageryAddPanel.add(tabbedPane, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     96        add(tabbedPane, GBC.eop().insets(5,0,0,0).weight(1.0, 1.0).fill(GridBagConstraints.BOTH));
    9797
    9898        final JTextArea serviceUrlText = new JTextArea(3, 40);
     
    103103                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    104104                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    105         wmsFetchPanel.add(scrollPane, GBC.eop().insets(5,0,0,0));
     105        scrollPane.setMinimumSize(new Dimension(60, 60));
     106        wmsFetchPanel.add(scrollPane, GBC.eol().weight(1.0, 0.0).insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
    106107        JButton getLayersButton = new JButton(tr("Get Layers"));
    107108        getLayersButton.addActionListener(new ActionListener() {
     
    166167            }
    167168        });
    168         wmsFetchPanel.add(new JScrollPane(layerTree), GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     169        wmsFetchPanel.add(new JScrollPane(layerTree), GBC.eol().weight(1.0, 1.0).insets(5,0,0,0).fill(GridBagConstraints.BOTH));
    169170
    170171        JPanel layerManipulationButtons = new JPanel();
     
    202203                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
    203204                JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    204         tmsView.add(tmsUrlScrollPane, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     205        tmsUrlScrollPane.setMinimumSize(new Dimension(60, 60));
     206        tmsView.add(tmsUrlScrollPane, GBC.eol().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
    205207        tmsView.add(new JLabel(trc("layer", "Zoom")), GBC.std().insets(0,0,5,0));
    206208        tmsZoom = new JTextField(3);
     
    211213            }
    212214        });
    213         tmsView.add(tmsZoom, GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     215        tmsView.add(tmsZoom, GBC.eol().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     216        tmsView.add(new JLabel(), GBC.eop().weight(1.0, 1.0).fill(GridBagConstraints.BOTH));
    214217        tabbedPane.addTab(tr("TMS"), tmsView);
    215218
    216         imageryAddPanel.add(new JLabel(tr("Imagery URL")), GBC.std().insets(0,0,5,0));
     219        add(new JLabel(tr("Imagery URL")), GBC.std().insets(0,0,5,0));
    217220        resultingLayerField = new JTextArea(3, 40);
    218221        resultingLayerField.setLineWrap(true);
    219         imageryAddPanel.add(new JScrollPane(resultingLayerField, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), GBC.eop().insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
     222        JScrollPane bottomScrollPane = new JScrollPane(resultingLayerField,
     223                JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     224        bottomScrollPane.setMinimumSize(new Dimension(60, 60));
     225        add(bottomScrollPane, GBC.eol().weight(1.0, 0.0).insets(5,0,0,0).fill(GridBagConstraints.HORIZONTAL));
    220226
    221227        tabbedPane.addChangeListener(new ChangeListener() {
     
    232238            }
    233239        });
    234 
    235         add(imageryAddPanel);
    236240    }
    237241
     
    506510    }
    507511
    508     public static void main(String[] args) {
    509         JFrame f = new JFrame("Test");
    510         f.setContentPane(new AddWMSLayerPanel());
    511         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    512         f.pack();
    513         f.setVisible(true);
    514     }
    515 
    516512    private static String getChildContent(Element parent, String name, String missing, String empty) {
    517513        Element child = getChild(parent, name);
  • trunk/src/org/openstreetmap/josm/gui/preferences/ImageryPreference.java

    r4438 r4524  
    77import java.awt.Color;
    88import java.awt.Component;
     9import java.awt.Dialog;
    910import java.awt.Dimension;
    1011import java.awt.FlowLayout;
     
    1213import java.awt.GridBagConstraints;
    1314import java.awt.GridBagLayout;
     15import java.awt.Window;
    1416import java.awt.event.ActionEvent;
    1517import java.awt.event.ActionListener;
     18import java.awt.event.HierarchyEvent;
     19import java.awt.event.HierarchyListener;
    1620import java.awt.event.MouseEvent;
    1721import java.io.IOException;
     
    4650import javax.swing.JToolBar;
    4751import javax.swing.SpinnerNumberModel;
     52import javax.swing.SwingUtilities;
    4853import javax.swing.event.ChangeEvent;
    4954import javax.swing.event.ChangeListener;
     
    602607
    603608            public void actionPerformed(ActionEvent evt) {
    604                 AddWMSLayerPanel p = new AddWMSLayerPanel();
     609                final AddWMSLayerPanel p = new AddWMSLayerPanel();
     610                // This code snippet allows to resize the JOptionPane (fix #6090)
     611                p.addHierarchyListener(new HierarchyListener() {
     612                    public void hierarchyChanged(HierarchyEvent e) {
     613                        Window window = SwingUtilities.getWindowAncestor(p);
     614                        if (window instanceof Dialog) {
     615                            Dialog dialog = (Dialog)window;
     616                            if (!dialog.isResizable()) {
     617                                dialog.setResizable(true);
     618                                dialog.setMinimumSize(new Dimension(250, 350));
     619                            }
     620                        }
     621                    }
     622                });
    605623                int answer = JOptionPane.showConfirmDialog(
    606624                        gui, p,
    607625                        tr("Add Imagery URL"),
    608                         JOptionPane.OK_CANCEL_OPTION);
     626                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    609627                if (answer == JOptionPane.OK_OPTION) {
    610628                    model.addRow(new ImageryInfo(p.getUrlName(), p.getUrl()));
Note: See TracChangeset for help on using the changeset viewer.