changeset 11:5bbb436fbcf7

Fix the glitch of the JTextPane's sometimes being too tall.
author David Barts <n5jrn@me.com>
date Sun, 19 Jan 2020 19:39:52 -0800
parents e7e067f5b649
children 0fb6da371b80
files src/name/blackcap/clipman/Main.kt
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/name/blackcap/clipman/Main.kt	Sun Jan 19 18:24:20 2020 -0800
+++ b/src/name/blackcap/clipman/Main.kt	Sun Jan 19 19:39:52 2020 -0800
@@ -55,6 +55,12 @@
     }
 }
 
+class ClipText: JTextPane() {
+    override fun getMaximumSize(): Dimension {
+        return Dimension(Int.MAX_VALUE, preferredSize.height)
+    }
+}
+
 /* the updating thread */
 class UpdateIt(val queue: PasteboardQueue, val interval: Int): Thread() {
     @Volatile var enabled = true
@@ -89,7 +95,7 @@
                         when (contents) {
                             is PasteboardItem.Plain -> widget.run {
                                 add(stdLabel("Plain text"))
-                                add(JTextPane().apply {
+                                add(ClipText().apply {
                                     contentType = "text/plain"
                                     text = contents.plain
                                     font = Font(Font.MONOSPACED, Font.PLAIN, 14)
@@ -101,7 +107,7 @@
                             }
                             is PasteboardItem.HTML -> widget.run {
                                 add(stdLabel("Styled text"))
-                                add(JTextPane().apply {
+                                add(ClipText().apply {
                                     contentType = "text/html"
                                     toolTipText = "Styled text"
                                     text = scrub(contents.html)