Mercurial > cgi-bin > hgweb.cgi > ClipMan
changeset 1:fb224c3aebdf
Got it auto-scrolling to the bottom.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sat, 18 Jan 2020 09:12:58 -0800 |
parents | be282c48010a |
children | 6fb94eae32fa |
files | src/name/blackcap/clipman/PasteboardQueue.kt |
diffstat | 1 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/name/blackcap/clipman/PasteboardQueue.kt Tue Jan 14 14:07:19 2020 -0800 +++ b/src/name/blackcap/clipman/PasteboardQueue.kt Sat Jan 18 09:12:58 2020 -0800 @@ -5,8 +5,11 @@ package name.blackcap.clipman import java.awt.Container +import java.awt.Rectangle import java.util.Collections import java.util.LinkedList +import java.util.logging.Level +import java.util.logging.Logger import javax.swing.* /** @@ -33,11 +36,22 @@ } /** - * Add a JComponent to the end of the queue. - * @param item JComponent to add + * Add a QueueItem to the end of the queue. + * @param item QueueItem to add */ @Synchronized fun add(item: QueueItem) { - inSwingThread { parent.add(item.component) } + inSwingThread { + parent.add(item.component) + /* XXX - assumes there is a JScrollPane above us in the tree */ + var sp = parent.parent + while (sp != null && !(sp is JScrollPane)) { + sp = sp.parent + } + (sp as JScrollPane).run { + revalidate() + verticalScrollBar.run { value = maximum } + } + } queue.addLast(item) truncate(true) }