Mercurial > cgi-bin > hgweb.cgi > JpegWasher
diff src/name/blackcap/exifwasher/WashDialog.kt @ 7:65d14d44bc3f
Works, but the column layout numbers are WEIRD.
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 10 Apr 2020 13:44:04 -0700 |
parents | dc1f4359659d |
children | 88d02fa97d78 |
line wrap: on
line diff
--- 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<String>("Delete?", "Key", "Type", "Value") + private val myTable = JTable(arrayOf<Array<Any>>(), 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<Array<Any>>, cNames: Array<String>) : 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 } }