# HG changeset patch # User David Barts # Date 1581311606 25200 # Node ID d14298ef8b0a0840b6275af7028783a472123792 # Parent 339e2da5bf83536cbf983d3c396db314e2644048 Fix some settings/preferences issues. diff -r 339e2da5bf83 -r d14298ef8b0a src/name/blackcap/clipman/Files.kt --- a/src/name/blackcap/clipman/Files.kt Sun Feb 09 19:23:16 2020 -0700 +++ b/src/name/blackcap/clipman/Files.kt Sun Feb 09 22:13:26 2020 -0700 @@ -64,7 +64,7 @@ /* make some usable objects */ val DPROPERTIES = Properties().apply { - OS::class.java.getClassLoader().getResourceAsStream("default.properties").use { load(it) } + OS::class.java.getResourceAsStream("default.properties").use { load(it) } } val PROPERTIES = Properties(DPROPERTIES).apply { diff -r 339e2da5bf83 -r d14298ef8b0a src/name/blackcap/clipman/SettingsDialog.kt --- a/src/name/blackcap/clipman/SettingsDialog.kt Sun Feb 09 19:23:16 2020 -0700 +++ b/src/name/blackcap/clipman/SettingsDialog.kt Sun Feb 09 22:13:26 2020 -0700 @@ -3,6 +3,7 @@ */ package name.blackcap.clipman +import java.awt.Dimension import java.awt.event.ActionEvent import java.awt.event.ActionListener import java.io.BufferedWriter @@ -30,15 +31,18 @@ private val _qlSlider = JSlider(10000, 30000, spinToSlide(_qLength)).also { it.majorTickSpacing = 10000 it.paintTicks = true - it.labelTable = Hashtable().apply { - put(10000, "10") - put(20000, "100") - put(30000, "1000") + it.labelTable = Hashtable().apply { + put(10000, JLabel("10")) + put(20000, JLabel("100")) + put(30000, JLabel("1000")) } + it.paintLabels = true it.addChangeListener(this) } private val _qlSpinner = JSpinner(SpinnerNumberModel(_qLength, 10, 1000, 1)).also { it.addChangeListener(this) + it.maximumSize = Dimension(it.maximumSize.width, it.preferredSize.height) + (it.editor as? JSpinner.DefaultEditor)?.getTextField()?.setEditable(false) } val qLength: Int get() { @@ -111,10 +115,10 @@ } override fun stateChanged(e: ChangeEvent) { - when (val source = e.source) { - source === _qlSlider -> + when (e.source) { + is JSlider -> _qlSpinner.value = (10.0).pow(_qlSlider.value.toDouble() / 10000.0).roundToInt() - source === _qlSpinner -> + is JSpinner -> _qlSlider.value = spinToSlide(_qlSpinner.value as Int) } } @@ -156,6 +160,6 @@ val settingsDialog = SettingsDialog() -fun Properties.getString(key: String): String = get(key) as String +fun Properties.getString(key: String): String = getProperty(key) as String fun Properties.getInt(key: String): Int = getString(key).toInt()