changeset 32:4d87bedb3f65

Looks better, Still wrestling with the damned labels.
author David Barts <n5jrn@me.com>
date Thu, 30 Jan 2020 18:01:57 -0800
parents 0c6c18a733b7
children 277cbb78bc5a
files src/name/blackcap/clipman/CoerceDialog.kt
diffstat 1 files changed, 34 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/name/blackcap/clipman/CoerceDialog.kt	Thu Jan 30 16:01:51 2020 -0800
+++ b/src/name/blackcap/clipman/CoerceDialog.kt	Thu Jan 30 18:01:57 2020 -0800
@@ -28,6 +28,7 @@
     /* the proportional font family */
     private val _pFamily = JComboBox<String>(FONTS).apply {
         selectedIndex = getFontIndex(Font.SERIF)
+        alignmentX = JComboBox.LEFT_ALIGNMENT
     }
     val pFamily: String
     get() {
@@ -37,6 +38,7 @@
     /* the proportional font size */
     private val _pSize = JComboBox<Float>(SIZES).also {
         it.selectedIndex = DSIZEI
+        it.alignmentX = JComboBox.LEFT_ALIGNMENT
         it.setEditable(true)
         it.actionCommand = "Size"
         it.addActionListener(this)
@@ -49,6 +51,7 @@
     /* the monospaced font family */
     private val _mFamily = JComboBox<String>(FONTS).apply {
         selectedIndex = getFontIndex(Font.MONOSPACED)
+        alignmentX = JComboBox.LEFT_ALIGNMENT
     }
     val mFamily: String
     get() {
@@ -58,6 +61,7 @@
     /* the monospaced font size */
     private val _mSize = JComboBox<Float>(SIZES).also {
         it.selectedIndex = DSIZEI
+        it.alignmentX = JComboBox.LEFT_ALIGNMENT
         it.setEditable(true)
         it.actionCommand = "Size"
         it.addActionListener(this)
@@ -70,9 +74,6 @@
     /* standard spacing between elements (10 pixels ≅ 1/7") and half that */
     private val BW = 5
     private val BW2 = 10
-    private val VSPACE = Box.createVerticalStrut(BW)
-    private val VSPACE2 = Box.createVerticalStrut(BW2)
-    private val HSPACE2 = Box.createHorizontalStrut(BW2)
 
     /* buttons */
     private val _coerce = JButton("Coerce").also {
@@ -90,66 +91,73 @@
         title = "Coerce Fonts"
         contentPane.apply {
             add(Box(BoxLayout.Y_AXIS).apply {
-                add(VSPACE2)
-                add(leftLabel("Coerce proportionally-spaced text to:"))
-                add(VSPACE)
+                alignmentX = Box.CENTER_ALIGNMENT
+                add(JLabel("Coerce proportionally-spaced text to:").apply {
+                    horizontalAlignment = JLabel.CENTER
+                    alignmentX = JLabel.CENTER_ALIGNMENT
+                    border = BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2)
+                })
                 add(Box(BoxLayout.X_AXIS).apply {
-                    add(HSPACE2)
+                    border = BorderFactory.createEmptyBorder(0, BW2, BW, BW2)
                     add(Box.createGlue())
                     add(Box(BoxLayout.Y_AXIS).apply {
-                        add(leftLabel("Family:"))
+                        add(JLabel("Family:").apply {
+                            horizontalAlignment = JLabel.CENTER
+                            alignmentX = JLabel.LEFT_ALIGNMENT
+                        })
                         add(_pFamily)
                     })
                     add(Box.createGlue())
                     add(Box(BoxLayout.Y_AXIS).apply {
-                        add(leftLabel("Size:"))
+                        add(JLabel("Size:").apply {
+                            horizontalAlignment = JLabel.CENTER
+                            alignmentX = JLabel.LEFT_ALIGNMENT
+                        })
                         add(_pSize)
                     })
                     add(Box.createGlue())
-                    add(HSPACE2)
                 })
-                add(VSPACE2)
                 add(JSeparator())
-                add(VSPACE2)
-                add(leftLabel("Coerce monospaced text to:"))
-                add(VSPACE)
+                add(JLabel("Coerce monospaced text to:").apply {
+                    horizontalAlignment = JLabel.CENTER
+                    alignmentX = JLabel.CENTER_ALIGNMENT
+                    border = BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2)
+                })
                 add(Box(BoxLayout.X_AXIS).apply {
-                    add(HSPACE2)
+                    border = BorderFactory.createEmptyBorder(0, BW2, BW, BW2)
                     add(Box.createGlue())
                     add(Box(BoxLayout.Y_AXIS).apply {
-                        add(leftLabel("Family:"))
+                        add(JLabel("Family:").apply {
+                            horizontalAlignment = JLabel.CENTER
+                            alignmentX = JLabel.LEFT_ALIGNMENT
+                        })
                         add(_mFamily)
                     })
                     add(Box.createGlue())
                     add(Box(BoxLayout.Y_AXIS).apply {
-                        add(leftLabel("Size:"))
+                        add(JLabel("Size:").apply {
+                            horizontalAlignment = JLabel.CENTER
+                            alignmentX = JLabel.LEFT_ALIGNMENT
+                        })
                         add(_mSize)
                     })
                     add(Box.createGlue())
-                    add(HSPACE2)
                 })
-                add(VSPACE2)
                 add(JSeparator())
-                add(VSPACE2)
                 add(Box(BoxLayout.X_AXIS).apply {
+                    border = BorderFactory.createEmptyBorder(BW2, BW2, BW2, BW2)
                     add(Box.createGlue())
                     add(_cancel)
                     add(Box.createGlue())
                     add(_coerce)
                     add(Box.createGlue())
                 })
-                add(VSPACE2)
             })
         }
         rootPane.setDefaultButton(_coerce)
         pack()
     }
 
-    private fun leftLabel(text: String) = JLabel(text).apply {
-        horizontalAlignment = JLabel.LEFT
-        alignmentX = JLabel.LEFT_ALIGNMENT
-    }
-
     override fun actionPerformed(e: ActionEvent) {
         when (e.actionCommand) {
             "Size" -> {