# HG changeset patch # User David Barts # Date 1580436117 28800 # Node ID 4d87bedb3f650cf60679edf030ccd7f4bc6768d2 # Parent 0c6c18a733b7330397d71bef2c26bfe4f6f0c5c4 Looks better, Still wrestling with the damned labels. diff -r 0c6c18a733b7 -r 4d87bedb3f65 src/name/blackcap/clipman/CoerceDialog.kt --- 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(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(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(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(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" -> {