# HG changeset patch # User David Barts # Date 1579491592 28800 # Node ID 5bbb436fbcf7aee3330f9213236875d485a9d9f9 # Parent e7e067f5b649a808978b2ee45693fe14050e5f9c Fix the glitch of the JTextPane's sometimes being too tall. diff -r e7e067f5b649 -r 5bbb436fbcf7 src/name/blackcap/clipman/Main.kt --- 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)