diff src/name/blackcap/imageprep/SettingsDialog.kt @ 26:9bf3d8de6904

Fix Preferences bug, bump version number.
author David Barts <n5jrn@me.com>
date Sun, 13 Dec 2020 11:20:06 -0800
parents d3979a2155a8
children 098c4f5507c7
line wrap: on
line diff
--- a/src/name/blackcap/imageprep/SettingsDialog.kt	Wed Nov 25 08:40:45 2020 -0800
+++ b/src/name/blackcap/imageprep/SettingsDialog.kt	Sun Dec 13 11:20:06 2020 -0800
@@ -15,6 +15,8 @@
 import java.util.logging.Level
 import java.util.logging.Logger
 import javax.swing.*
+import javax.swing.event.ChangeEvent
+import javax.swing.event.ChangeListener
 import kotlin.text.toInt
 
 /* work around name shadowing */
@@ -44,8 +46,21 @@
         return _outputSuffix.text
     }
     
+    /* button to change that other directory */
+    private val otid = _PROPS.getBoolean("outputToInputDir")
+    protected val changeOutputTo = JButton("Change").also {
+        it.noTaller()
+        it.addActionListener(ActionListener {
+            val status = _outputTo.showOpenDialog(this)
+            if (status == JFileChooser.APPROVE_OPTION) {
+                val path = outputTo
+                outputToText.text = path
+            }
+        })
+        it.setEnabled(!otid)
+    }
+    
     /* output to input dir? */
-    private val otid = _PROPS.getBoolean("outputToInputDir")
     private val outputToInputButton = JRadioButton("Create output file in same folder as input.", otid).apply {
         alignmentX = LEFT_ALIGNMENT
     }
@@ -57,6 +72,9 @@
     /* output to some other directory */
     private val outputToButton = JRadioButton("Create output file in:", !otid).apply {
         alignmentX = LEFT_ALIGNMENT
+        addChangeListener(ChangeListener {
+            changeOutputTo.setEnabled(isSelected())
+        })
     }
     
     /* name of the other directory */
@@ -76,19 +94,6 @@
         return _outputTo.selectedFile?.getCanonicalPath() ?: oto
     }
     
-    /* button to change that other directory */
-    protected val changeOutputTo = JButton("Change").also {
-        it.noTaller()
-        it.addActionListener(ActionListener {
-            val status = _outputTo.showOpenDialog(this)
-            if (status == JFileChooser.APPROVE_OPTION) {
-                val path = outputTo
-                outputToText.text = path
-            }
-        })
-        it.setEnabled(!otid)
-    }
-    
     /* radio button group */
     protected val buttonGroup = ButtonGroup().apply {
         add(outputToButton)