Mercurial > cgi-bin > hgweb.cgi > ClipMan
comparison src/name/blackcap/clipman/Main.kt @ 6:0640efd6b54a
Tweak borders (incomplete).
author | David Barts <n5jrn@me.com> |
---|---|
date | Sun, 19 Jan 2020 10:53:38 -0800 |
parents | debe0413280f |
children | fbb3a6999590 |
comparison
equal
deleted
inserted
replaced
5:d832c7b2bfd0 | 6:0640efd6b54a |
---|---|
36 override fun windowOpened(e: WindowEvent) {} | 36 override fun windowOpened(e: WindowEvent) {} |
37 | 37 |
38 // and the one we do | 38 // and the one we do |
39 override fun windowClosing(e: WindowEvent) { | 39 override fun windowClosing(e: WindowEvent) { |
40 thr.run { interrupt(); join() } | 40 thr.run { interrupt(); join() } |
41 LOGGER.log(Level.INFO, "execution complete") | |
41 System.exit(0) | 42 System.exit(0) |
42 } | 43 } |
43 } | 44 } |
44 | 45 |
45 /* the updating thread */ | 46 /* the updating thread */ |
46 class UpdateIt(val queue: PasteboardQueue, val interval: Int): Thread() { | 47 class UpdateIt(val queue: PasteboardQueue, val interval: Int): Thread() { |
47 @Volatile var enabled = true | 48 @Volatile var enabled = true |
48 private val stdBorder = | 49 private val stdBorder = |
49 CompoundBorder(EmptyBorder(5, 10, 5, 10), LineBorder(Color.GRAY, 1)) | 50 CompoundBorder(LineBorder(Color(0xeeeeee), 9), LineBorder(Color.GRAY, 1)) |
50 | 51 |
51 override fun run() { | 52 override fun run() { |
52 var oldContents = "" | 53 var oldContents = "" |
53 var newContents = "" | 54 var newContents = "" |
54 while (true) { | 55 while (true) { |
106 } | 107 } |
107 } | 108 } |
108 | 109 |
109 fun main(args: Array<String>) { | 110 fun main(args: Array<String>) { |
110 LOGGER.log(Level.INFO, "beginning execution") | 111 LOGGER.log(Level.INFO, "beginning execution") |
112 val frame = JFrame("ClipMan").apply { preferredSize = Dimension(640, 480) } | |
111 val con = JPanel().apply { | 113 val con = JPanel().apply { |
112 layout = BoxLayout(this, BoxLayout.Y_AXIS) | 114 layout = BoxLayout(this, BoxLayout.Y_AXIS) |
115 border = EmptyBorder(9, 9, 9, 9) | |
116 background = frame.background | |
113 } | 117 } |
114 var frame: JFrame? = null | |
115 inSwingThread { | 118 inSwingThread { |
116 frame = JFrame("ClipMan").apply { | 119 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
117 preferredSize = Dimension(640, 480) | 120 frame.apply { |
118 contentPane.add( | 121 contentPane.add( |
119 JScrollPane(con).apply { | 122 JScrollPane(con).apply { |
120 verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED | 123 verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED |
121 horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER | 124 horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER |
122 preferredSize = Dimension(640, 480) | 125 preferredSize = Dimension(640, 480) |
126 background = frame.background | |
123 }, BorderLayout.CENTER) | 127 }, BorderLayout.CENTER) |
124 pack() | 128 pack() |
125 setVisible(true) | 129 setVisible(true) |
126 } | 130 } |
127 } | 131 } |
128 val queue = PasteboardQueue(con, 10) | 132 val queue = PasteboardQueue(con, 10) |
129 val updater = UpdateIt(queue, 1000).apply { start() } | 133 val updater = UpdateIt(queue, 1000).apply { start() } |
130 inSwingThread { frame?.addWindowListener(KillIt(updater)) } | 134 inSwingThread { frame.addWindowListener(KillIt(updater)) } |
131 LOGGER.log(Level.INFO, "execution complete") | |
132 } | 135 } |
133 | 136 |
134 fun inSwingThread(block: () -> Unit) { | 137 fun inSwingThread(block: () -> Unit) { |
135 SwingUtilities.invokeLater(Runnable(block)) | 138 SwingUtilities.invokeLater(Runnable(block)) |
136 } | 139 } |