- Timestamp:
- 2013-03-19T11:59:21+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r5763 r5784 83 83 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 84 84 import org.openstreetmap.josm.gui.util.FileFilterAllFiles; 85 import org.openstreetmap.josm.gui.util.TableHelper; 85 86 import org.openstreetmap.josm.gui.widgets.JFileChooserManager; 86 87 import org.openstreetmap.josm.io.MirroredInputStream; … … 154 155 @Override 155 156 public void tableChanged(TableModelEvent e) { 156 adjustColumnWidth(tblActiveSources, isMapPaint ? 1 :0);157 TableHelper.adjustColumnWidth(tblActiveSources, isMapPaint ? 1 : 0, 800); 157 158 } 158 159 }); … … 387 388 LOADING_SOURCES_FROM, FAILED_TO_LOAD_SOURCES_FROM, FAILED_TO_LOAD_SOURCES_FROM_HELP_TOPIC, 388 389 ILLEGAL_FORMAT_OF_ENTRY } 389 390 /**391 * adjust the preferred width of column col to the maximum preferred width of the cells392 * requires JTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);393 */394 private static void adjustColumnWidth(JTable tbl, int col) {395 int maxwidth = 0;396 for (int row=0; row<tbl.getRowCount(); row++) {397 TableCellRenderer tcr = tbl.getCellRenderer(row, col);398 Object val = tbl.getValueAt(row, col);399 Component comp = tcr.getTableCellRendererComponent(tbl, val, false, false, row, col);400 maxwidth = Math.max(comp.getPreferredSize().width, maxwidth);401 }402 tbl.getColumnModel().getColumn(col).setPreferredWidth(maxwidth);403 }404 390 405 391 public boolean hasActiveSourcesChanged() { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r5707 r5784 27 27 import org.openstreetmap.josm.data.osm.OsmPrimitive; 28 28 import org.openstreetmap.josm.gui.ExtendedDialog; 29 import org.openstreetmap.josm.gui.util.TableHelper; 29 30 import org.openstreetmap.josm.tools.GBC; 30 31 … … 110 111 }; 111 112 113 propertyTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); 112 114 // a checkbox has a size of 15 px 113 115 propertyTable.getColumnModel().getColumn(0).setMaxWidth(15); 116 TableHelper.adjustColumnWidth(propertyTable, 1, 200); 117 TableHelper.adjustColumnWidth(propertyTable, 2, 700); 114 118 // get edit results if the table looses the focus, for example if a user clicks "add tags" 115 119 propertyTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); … … 128 132 setContent(tablePanel); 129 133 setDefaultButton(2); 130 // set the default Dimensions and show the dialog131 setPreferredSize(new Dimension(400,tablePanel.getPreferredSize().height+100));132 134 } 133 135
Note:
See TracChangeset
for help on using the changeset viewer.