Mercurial > cgi-bin > hgweb.cgi > ClipMan
diff src/name/blackcap/clipman/SettingsDialog.kt @ 44:d14298ef8b0a
Fix some settings/preferences issues.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sun, 09 Feb 2020 22:13:26 -0700 |
parents | 339e2da5bf83 |
children | ca8a23bae4fa |
line wrap: on
line diff
--- 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<Int, String>().apply { - put(10000, "10") - put(20000, "100") - put(30000, "1000") + it.labelTable = Hashtable<Int, JComponent>().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()