# HG changeset patch # User David Barts # Date 1580450797 28800 # Node ID 08eaae2aaf7622a9462d9784c45cf177431d5e4a # Parent 9890445e4cc4bc39b11e311b8e685997022b4bac Stop dialog resizing, fix detection of bad font sizes. diff -r 9890445e4cc4 -r 08eaae2aaf76 src/name/blackcap/clipman/CoerceDialog.kt --- a/src/name/blackcap/clipman/CoerceDialog.kt Thu Jan 30 21:03:56 2020 -0800 +++ b/src/name/blackcap/clipman/CoerceDialog.kt Thu Jan 30 22:06:37 2020 -0800 @@ -42,8 +42,6 @@ it.selectedIndex = DSIZEI it.alignmentX = JComboBox.LEFT_ALIGNMENT it.setEditable(true) - it.actionCommand = "Size" - it.addActionListener(this) } val pSize: Float get() { @@ -65,8 +63,6 @@ it.selectedIndex = DSIZEI it.alignmentX = JComboBox.LEFT_ALIGNMENT it.setEditable(true) - it.actionCommand = "Size" - it.addActionListener(this) } val mSize: Float get() { @@ -148,17 +144,11 @@ } rootPane.setDefaultButton(_coerce) pack() + setResizable(false) } override fun actionPerformed(e: ActionEvent) { when (e.actionCommand) { - "Size" -> { - val source = e.source as? JComboBox - if (source != null && (source.selectedItem as Float) < 1.0f) { - Toolkit.getDefaultToolkit().beep() - source.selectedIndex = DSIZEI - } - } "Coerce" -> { setVisible(false) coerce() @@ -193,6 +183,9 @@ "Error", JOptionPane.ERROR_MESSAGE) } else { + if (badSize(_pSize, "proportionally-spaced") || badSize(_mSize, "monospaced")) { + return + } PasteboardItem.write( PasteboardItem.HTML( plain, @@ -202,6 +195,19 @@ } } + private fun badSize(control: JComboBox, fontType: String): Boolean { + val size = control.selectedItem as? Float + if (size == null || size < 1.0f) { + JOptionPane.showMessageDialog(frame.v, + "Invalid ${fontType} font size.", + "Error", + JOptionPane.ERROR_MESSAGE) + control.selectedIndex = DSIZEI + return true + } + return false + } + private fun getFontIndex(font: String): Int { val found = FONTS.indexOf(font) if (found < 0) { diff -r 9890445e4cc4 -r 08eaae2aaf76 src/name/blackcap/clipman/SearchDialog.kt --- a/src/name/blackcap/clipman/SearchDialog.kt Thu Jan 30 21:03:56 2020 -0800 +++ b/src/name/blackcap/clipman/SearchDialog.kt Thu Jan 30 22:06:37 2020 -0800 @@ -126,6 +126,7 @@ } rootPane.setDefaultButton(_find) pack() + setResizable(false) } override fun actionPerformed(e: ActionEvent) {