diff src/name/blackcap/exifwasher/Misc.kt @ 9:0a106e9b91b4

Fix table layout; fix "select all for deletion" feature.
author David Barts <n5jrn@me.com>
date Fri, 10 Apr 2020 19:17:09 -0700
parents 88d02fa97d78
children 39b977021ea1
line wrap: on
line diff
--- a/src/name/blackcap/exifwasher/Misc.kt	Fri Apr 10 15:09:36 2020 -0700
+++ b/src/name/blackcap/exifwasher/Misc.kt	Fri Apr 10 19:17:09 2020 -0700
@@ -175,9 +175,9 @@
 fun JTable.setColWidth(col: Int, width: Int, string: String?) {
     val FUZZ = 4
     columnModel.getColumn(col).preferredWidth = if (string.isNullOrEmpty()) {
-        width + FUZZ
+        width
     } else {
-        maxOf(width, graphics.fontMetrics.stringWidth(string)) + FUZZ
+        maxOf(width, graphics.fontMetrics.stringWidth(string) + FUZZ)
     }
 }
 
@@ -186,8 +186,9 @@
  */
 fun JTable.setOverallWidth() {
     val tcm = columnModel
+    val limit = tcm.columnCount - 1
     var total = 0
-    for (i in 0 .. tcm.columnCount - 1) {
+    for (i in 0 .. limit) {
         total += tcm.getColumn(i).preferredWidth
     }
     preferredSize = Dimension(total, preferredSize.height)