# HG changeset patch # User David Barts # Date 1586551444 25200 # Node ID 65d14d44bc3f2749a2d8501e232f7cdf610b35e5 # Parent aafc9c127c7b723e1af2aea065d5eee2016dd396 Works, but the column layout numbers are WEIRD. diff -r aafc9c127c7b -r 65d14d44bc3f src/name/blackcap/exifwasher/ShowDialog.kt --- a/src/name/blackcap/exifwasher/ShowDialog.kt Thu Apr 09 22:29:48 2020 -0700 +++ b/src/name/blackcap/exifwasher/ShowDialog.kt Fri Apr 10 13:44:04 2020 -0700 @@ -24,7 +24,8 @@ private val WIDTH = 640 private val HEIGHT = 480 - private val myTable = JTable().apply { + private val COLUMN_NAMES = arrayOf("Key", "Type", "Value") + private val myTable = JTable(arrayOf>(), COLUMN_NAMES).apply { autoCreateRowSorter = false rowSorter = null columnModel.run { @@ -69,11 +70,7 @@ "Unable to read metadata.", "Error", JOptionPane.ERROR_MESSAGE) } else { - val colNames = arrayOf("Key", "Type", "Value") - myTable.apply { - model = MyTableModel(tableData, colNames) - validate() - } + myTable.model = MyTableModel(tableData, COLUMN_NAMES) setVisible(true) } } @@ -82,7 +79,7 @@ private class MyTableModel(tData: Array>, cNames: Array) : DefaultTableModel(tData, cNames) { override fun isCellEditable(row: Int, col: Int) = false - override fun getColumnClass(col: Int) = String::class.java + override fun getColumnClass(col: Int) = java.lang.String::class.java } init { diff -r aafc9c127c7b -r 65d14d44bc3f src/name/blackcap/exifwasher/WashDialog.kt --- a/src/name/blackcap/exifwasher/WashDialog.kt Thu Apr 09 22:29:48 2020 -0700 +++ b/src/name/blackcap/exifwasher/WashDialog.kt Fri Apr 10 13:44:04 2020 -0700 @@ -25,33 +25,25 @@ private val WIDTH = 640 private val HEIGHT = 480 - private val myTable = JTable().apply { + private val COLUMN_NAMES = arrayOf("Delete?", "Key", "Type", "Value") + private val myTable = JTable(arrayOf>(), COLUMN_NAMES).apply { autoCreateRowSorter = false rowSorter = null - columnModel.run { - getColumn(0).preferredWidth = 10 /* checkbox */ - getColumn(1).preferredWidth = 25 /* key name */ - getColumn(2).preferredWidth = 15 /* type */ - getColumn(3).preferredWidth = 100 /* value */ - } } private val selectAll = JCheckBox("Select all for deletion", false) private val resetButton = JButton("Reset").also { it.addActionListener(ActionListener { doReset() }) - it.border = BorderFactory.createEmptyBorder(0, BW, 0, BW) } private val cancelButton = JButton("Cancel").also { it.addActionListener(ActionListener { close() }) - it.border = BorderFactory.createEmptyBorder(0, BW, 0, BW) } /* deliberately not the default action, because it changes a file */ private val washButton = JButton("Wash").also { it.addActionListener(ActionListener { doWash() }) - it.border = BorderFactory.createEmptyBorder(0, BW, 0, BW) } private lateinit var washing: File @@ -89,10 +81,18 @@ "Unable to read metadata.", "Error", JOptionPane.ERROR_MESSAGE) } else { - val colNames = arrayOf("Delete?", "Key", "Type", "Value") - myTable.apply { - model = MyTableModel(tableData, colNames) - validate() + myTable.run { + model = MyTableModel(tableData, COLUMN_NAMES) + columnModel.run { + getColumn(0).run { + preferredWidth = 10 + maxWidth = 850000000 /* xxx - don't ask */ + } + getColumn(1).preferredWidth = 100 /* key name */ + getColumn(2).preferredWidth = 5 /* type */ + getColumn(3).preferredWidth = 200 /* value */ + } + autoResizeMode = JTable.AUTO_RESIZE_LAST_COLUMN } setVisible(true) } @@ -103,9 +103,9 @@ private class MyTableModel(tData: Array>, cNames: Array) : DefaultTableModel(tData, cNames) { override fun isCellEditable(row: Int, col: Int) = col == 0 override fun getColumnClass(col: Int) = if (col == 0) { - Boolean::class.java + java.lang.Boolean::class.java } else { - String::class.java + java.lang.String::class.java } }