Changeset 2043 in josm
- Timestamp:
- 2009-09-03T19:06:28+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2040 r2043 321 321 322 322 final JScrollPane scrollPane = new JScrollPane(memberTable); 323 // this adapters ensures that the width of the tag table columns is adjusted324 // to the width of the scroll pane viewport. Also tried to overwrite325 // getPreferredViewportSize() in JTable, but did not work.326 //327 scrollPane.addComponentListener(new ComponentAdapter() {328 @Override329 public void componentResized(ComponentEvent e) {330 super.componentResized(e);331 Dimension d = scrollPane.getViewport().getExtentSize();332 memberTable.adjustColumnWidth(d.width);333 }334 });335 323 336 324 GridBagConstraints gc = new GridBagConstraints(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTable.java
r1884 r2043 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Container; 7 import java.awt.Dimension; 6 8 import java.awt.event.ActionEvent; 7 9 import java.awt.event.KeyEvent; … … 13 15 import javax.swing.JPopupMenu; 14 16 import javax.swing.JTable; 17 import javax.swing.JViewport; 15 18 import javax.swing.KeyStroke; 16 19 import javax.swing.ListSelectionModel; … … 72 75 } 73 76 74 /** 75 * adjusts the width of the columns for the tag name and the tag value to the width of the 76 * scroll panes viewport. 77 * 78 * Note: {@see #getPreferredScrollableViewportSize()} did not work as expected 79 * 80 * @param scrollPaneWidth the width of the scroll panes viewport 81 */ 82 public void adjustColumnWidth(int scrollPaneWidth) { 83 TableColumnModel tcm = getColumnModel(); 84 int width = scrollPaneWidth; 85 width = width / 3; 86 if (width > 0) { 87 tcm.getColumn(0).setMinWidth(width); 88 tcm.getColumn(0).setMaxWidth(width); 89 tcm.getColumn(1).setMinWidth(width); 90 tcm.getColumn(1).setMaxWidth(width); 91 tcm.getColumn(2).setMinWidth(width); 92 tcm.getColumn(2).setMaxWidth(width); 93 94 } 77 @Override 78 public Dimension getPreferredSize(){ 79 Container c = getParent(); 80 while(c != null && ! (c instanceof JViewport)) { 81 c = c.getParent(); 82 } 83 if (c != null) { 84 Dimension d = super.getPreferredSize(); 85 d.width = c.getSize().width; 86 return d; 87 } 88 return super.getPreferredSize(); 95 89 } 96 90
Note:
See TracChangeset
for help on using the changeset viewer.