annotate src/name/blackcap/clipman/SettingsDialog.kt @ 54:a9d5c94a177c

Add README file.
author David Barts <n5jrn@me.com>
date Tue, 13 Apr 2021 10:33:33 -0700
parents 19d9da731c43
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
1 /*
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
2 * The dialog that controls font corecion.
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
3 */
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
4 package name.blackcap.clipman
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
5
44
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
6 import java.awt.Dimension
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
7 import java.awt.event.ActionEvent
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
8 import java.awt.event.ActionListener
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
9 import java.io.BufferedWriter
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
10 import java.io.FileOutputStream
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
11 import java.io.IOException
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
12 import java.io.OutputStreamWriter
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
13 import java.util.Hashtable
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
14 import java.util.Properties
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
15 import java.util.logging.Level
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
16 import java.util.logging.Logger
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
17 import javax.swing.*
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
18 import javax.swing.event.ChangeEvent
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
19 import javax.swing.event.ChangeListener
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
20 import kotlin.math.log10
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
21 import kotlin.math.pow
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
22 import kotlin.math.roundToInt
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
23 import kotlin.text.toInt
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
24
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
25 /* work around name shadowing */
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
26 private val _PROPS = PROPERTIES
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
27
47
19d9da731c43 Recoded; cleaned up root namespace, removed race conditions.
David Barts <n5jrn@me.com>
parents: 45
diff changeset
28 class SettingsDialog: JDialog(Application.frame), ActionListener, ChangeListener {
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
29 /* max queue length */
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
30 private val _qLength = _PROPS.getInt("queue.length")
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
31 private val _qlSlider = JSlider(10000, 30000, spinToSlide(_qLength)).also {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
32 it.majorTickSpacing = 10000
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
33 it.paintTicks = true
44
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
34 it.labelTable = Hashtable<Int, JComponent>().apply {
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
35 put(10000, JLabel("10"))
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
36 put(20000, JLabel("100"))
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
37 put(30000, JLabel("1000"))
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
38 }
44
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
39 it.paintLabels = true
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
40 it.addChangeListener(this)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
41 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
42 private val _qlSpinner = JSpinner(SpinnerNumberModel(_qLength, 10, 1000, 1)).also {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
43 it.addChangeListener(this)
44
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
44 it.maximumSize = Dimension(it.maximumSize.width, it.preferredSize.height)
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
45 (it.editor as? JSpinner.DefaultEditor)?.getTextField()?.setEditable(false)
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
46 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
47 val qLength: Int
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
48 get() {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
49 return _qlSpinner.value as Int
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
50 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
51
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
52 /* standard spacing between elements (10 pixels ≅ 1/7") and half that */
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
53 private val BW = 5
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
54 private val BW2 = 10
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
55
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
56 /* buttons */
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
57 private val _ok = JButton("OK").also {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
58 it.actionCommand = "OK"
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
59 it.addActionListener(this)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
60 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
61
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
62 private val _cancel = JButton("Cancel").also {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
63 it.actionCommand = "Cancel"
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
64 it.addActionListener(this)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
65 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
66
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
67 /* initializer */
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
68 init {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
69 title = "Preferences"
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
70 contentPane.apply {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
71 add(Box(BoxLayout.Y_AXIS).apply {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
72 add(Box(BoxLayout.Y_AXIS).apply {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
73 alignmentX = Box.CENTER_ALIGNMENT
45
ca8a23bae4fa Adjust spacing in preferences.
David Barts <n5jrn@me.com>
parents: 44
diff changeset
74 border = BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2)
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
75 add(leftLabel("Maximum queue size:"))
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
76 add(Box.createVerticalStrut(BW))
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
77 add(Box(BoxLayout.X_AXIS).apply {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
78 alignmentX = Box.LEFT_ALIGNMENT
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
79 add(Box.createGlue())
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
80 add(_qlSlider)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
81 add(Box.createGlue())
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
82 add(_qlSpinner)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
83 add(Box.createGlue())
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
84 })
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
85 })
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
86 add(JSeparator())
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
87 add(Box(BoxLayout.X_AXIS).apply {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
88 alignmentX = Box.CENTER_ALIGNMENT
45
ca8a23bae4fa Adjust spacing in preferences.
David Barts <n5jrn@me.com>
parents: 44
diff changeset
89 border = BorderFactory.createEmptyBorder(BW, BW2, BW2, BW2)
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
90 add(Box.createGlue())
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
91 add(_cancel)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
92 add(Box.createGlue())
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
93 add(_ok)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
94 add(Box.createGlue())
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
95 })
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
96 })
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
97 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
98 rootPane.setDefaultButton(_ok)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
99 pack()
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
100 setResizable(false)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
101 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
102
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
103 override fun actionPerformed(e: ActionEvent) {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
104 when (e.actionCommand) {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
105 "OK" -> {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
106 writeProperties()
47
19d9da731c43 Recoded; cleaned up root namespace, removed race conditions.
David Barts <n5jrn@me.com>
parents: 45
diff changeset
107 Application.queue.maxSize = qLength
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
108 setVisible(false)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
109 }
43
339e2da5bf83 Simplified the settings. Compiles, not tested.
David Barts <n5jrn@me.com>
parents: 41
diff changeset
110 "Cancel" -> {
339e2da5bf83 Simplified the settings. Compiles, not tested.
David Barts <n5jrn@me.com>
parents: 41
diff changeset
111 revertValues()
339e2da5bf83 Simplified the settings. Compiles, not tested.
David Barts <n5jrn@me.com>
parents: 41
diff changeset
112 setVisible(false)
339e2da5bf83 Simplified the settings. Compiles, not tested.
David Barts <n5jrn@me.com>
parents: 41
diff changeset
113 }
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
114 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
115 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
116
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
117 override fun stateChanged(e: ChangeEvent) {
44
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
118 when (e.source) {
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
119 is JSlider ->
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
120 _qlSpinner.value = (10.0).pow(_qlSlider.value.toDouble() / 10000.0).roundToInt()
44
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
121 is JSpinner ->
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
122 _qlSlider.value = spinToSlide(_qlSpinner.value as Int)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
123 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
124 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
125
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
126 private fun spinToSlide(value: Int): Int =
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
127 (log10(value.toDouble()) * 10000.0).roundToInt()
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
128
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
129 private fun leftLabel(text: String) = JLabel(text).apply {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
130 alignmentX = JLabel.LEFT_ALIGNMENT
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
131 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
132
43
339e2da5bf83 Simplified the settings. Compiles, not tested.
David Barts <n5jrn@me.com>
parents: 41
diff changeset
133 private fun revertValues()
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
134 {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
135 val ql = _PROPS.getInt("queue.length")
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
136 _qlSpinner.value = ql
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
137 _qlSlider.value = spinToSlide(ql)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
138 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
139
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
140 private fun writeProperties()
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
141 {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
142 try {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
143 BufferedWriter(OutputStreamWriter(FileOutputStream(PROP_FILE), CHARSET)).use {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
144 _PROPS.put("queue.length", qLength.toString())
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
145 _PROPS.store(it, null)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
146 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
147 } catch (e: IOException) {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
148 LOGGER.log(Level.WARNING, "IOException writing properties file")
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
149 val message = e.message
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
150 if (message != null && !message.isEmpty()) {
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
151 LOGGER.log(Level.WARNING, message)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
152 }
47
19d9da731c43 Recoded; cleaned up root namespace, removed race conditions.
David Barts <n5jrn@me.com>
parents: 45
diff changeset
153 JOptionPane.showMessageDialog(Application.frame,
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
154 "Unable to write settings.",
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
155 "Error",
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
156 JOptionPane.ERROR_MESSAGE)
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
157 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
158 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
159 }
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
160
44
d14298ef8b0a Fix some settings/preferences issues.
David Barts <n5jrn@me.com>
parents: 43
diff changeset
161 fun Properties.getString(key: String): String = getProperty(key) as String
41
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
162
33fbe3a78d84 Got the settings stuff compiling (untested).
David Barts <n5jrn@me.com>
parents:
diff changeset
163 fun Properties.getInt(key: String): Int = getString(key).toInt()