Changeset 4524 in josm
- Timestamp:
- 2011-10-19T01:49:40+02:00 (13 years ago)
- 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 7 7 import java.awt.Component; 8 8 import java.awt.Cursor; 9 import java.awt.Dimension; 9 10 import java.awt.GridBagConstraints; 10 11 import java.awt.GridBagLayout; … … 27 28 import java.util.List; 28 29 import java.util.Set; 29 30 30 import java.util.regex.Pattern; 31 31 32 import javax.swing.JButton; 32 import javax.swing.JFrame;33 33 import javax.swing.JLabel; 34 34 import javax.swing.JOptionPane; … … 84 84 85 85 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)); 88 88 menuName = new JTextField(40); 89 89 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)); 91 91 92 92 final JTabbedPane tabbedPane = new JTabbedPane(); … … 94 94 final JPanel wmsFetchPanel = new JPanel(new GridBagLayout()); 95 95 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)); 97 97 98 98 final JTextArea serviceUrlText = new JTextArea(3, 40); … … 103 103 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 104 104 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)); 106 107 JButton getLayersButton = new JButton(tr("Get Layers")); 107 108 getLayersButton.addActionListener(new ActionListener() { … … 166 167 } 167 168 }); 168 wmsFetchPanel.add(new JScrollPane(layerTree), GBC.eo p().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)); 169 170 170 171 JPanel layerManipulationButtons = new JPanel(); … … 202 203 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, 203 204 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)); 205 207 tmsView.add(new JLabel(trc("layer", "Zoom")), GBC.std().insets(0,0,5,0)); 206 208 tmsZoom = new JTextField(3); … … 211 213 } 212 214 }); 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)); 214 217 tabbedPane.addTab(tr("TMS"), tmsView); 215 218 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)); 217 220 resultingLayerField = new JTextArea(3, 40); 218 221 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)); 220 226 221 227 tabbedPane.addChangeListener(new ChangeListener() { … … 232 238 } 233 239 }); 234 235 add(imageryAddPanel);236 240 } 237 241 … … 506 510 } 507 511 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 516 512 private static String getChildContent(Element parent, String name, String missing, String empty) { 517 513 Element child = getChild(parent, name); -
trunk/src/org/openstreetmap/josm/gui/preferences/ImageryPreference.java
r4438 r4524 7 7 import java.awt.Color; 8 8 import java.awt.Component; 9 import java.awt.Dialog; 9 10 import java.awt.Dimension; 10 11 import java.awt.FlowLayout; … … 12 13 import java.awt.GridBagConstraints; 13 14 import java.awt.GridBagLayout; 15 import java.awt.Window; 14 16 import java.awt.event.ActionEvent; 15 17 import java.awt.event.ActionListener; 18 import java.awt.event.HierarchyEvent; 19 import java.awt.event.HierarchyListener; 16 20 import java.awt.event.MouseEvent; 17 21 import java.io.IOException; … … 46 50 import javax.swing.JToolBar; 47 51 import javax.swing.SpinnerNumberModel; 52 import javax.swing.SwingUtilities; 48 53 import javax.swing.event.ChangeEvent; 49 54 import javax.swing.event.ChangeListener; … … 602 607 603 608 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 }); 605 623 int answer = JOptionPane.showConfirmDialog( 606 624 gui, p, 607 625 tr("Add Imagery URL"), 608 JOptionPane.OK_CANCEL_OPTION );626 JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); 609 627 if (answer == JOptionPane.OK_OPTION) { 610 628 model.addRow(new ImageryInfo(p.getUrlName(), p.getUrl()));
Note:
See TracChangeset
for help on using the changeset viewer.