Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Keyboard-macros/Scala/keyboard-macros.scala
Normal file
24
Task/Keyboard-macros/Scala/keyboard-macros.scala
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import java.awt.event.{KeyAdapter, KeyEvent}
|
||||
|
||||
import javax.swing.{JFrame, JLabel, WindowConstants}
|
||||
|
||||
|
||||
object KeyboardMacroDemo extends App {
|
||||
val directions = "<html><b>Ctrl-S</b> to show frame title<br>" + "<b>Ctrl-H</b> to hide it</html>"
|
||||
|
||||
new JFrame {
|
||||
add(new JLabel(directions))
|
||||
|
||||
addKeyListener(new KeyAdapter() {
|
||||
override def keyReleased(e: KeyEvent): Unit = {
|
||||
if (e.isControlDown && e.getKeyCode == KeyEvent.VK_S) setTitle("Hello there")
|
||||
else if (e.isControlDown && e.getKeyCode == KeyEvent.VK_H) setTitle("")
|
||||
}
|
||||
})
|
||||
|
||||
pack()
|
||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
|
||||
setVisible(true)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue