Created
March 7, 2019 10:32
-
-
Save NomadBlacky/a70d76f5d699994da83c92775935f3f6 to your computer and use it in GitHub Desktop.
何度閉じてもダイアログが出てくるScalaスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt._, event._ | |
import javax.swing._ | |
import scala.util.Random | |
val (screenCenterW, screenCenterH) = { | |
val ss = Toolkit.getDefaultToolkit().getScreenSize | |
(ss.getWidth.toInt / 2, ss.getHeight.toInt / 2) | |
} | |
val label = new JLabel("何回閉じても無駄ですよ~ww") | |
def randomLocation(): (Int, Int) = | |
(screenCenterW + Random.nextInt(200) - 200, screenCenterH + Random.nextInt(200) - 200) | |
def newDialog(): Unit = { | |
val dialog = new JDialog() | |
dialog.setSize(300, 200) | |
val (x, y) = randomLocation() | |
dialog.setLocation(x, y) | |
dialog.add(label) | |
dialog.setVisible(true) | |
dialog.addWindowListener(new WindowAdapter { | |
override def windowClosing(e: WindowEvent): Unit = { | |
newDialog() | |
} | |
}) | |
} | |
newDialog() |
Author
NomadBlacky
commented
Sep 16, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment