プロジェクト

全般

プロフィール

« | » 

リビジョン 51442fef

高徹 高橋 徹 さんがほぼ8年前に追加

メッセージのフォントを設定(色、大きさ)、フォントに合わせて画面サイズを設定

差分を表示:

learn/kotlin/javafx/MessageBoard/src/MessageBoard.kt
import javafx.animation.Interpolator
import javafx.animation.TranslateTransition
import javafx.application.Application
import javafx.geometry.Bounds
import javafx.scene.Group
import javafx.scene.Scene
import javafx.scene.paint.Color
import javafx.scene.text.Font
import javafx.scene.text.FontWeight
import javafx.scene.text.Text
import javafx.stage.Stage
import javafx.util.Duration
class MessageBoard : Application() {
override fun start(primaryStage: Stage?) {
val message = Text("Hello, world. This is JavaFX from Kotlin.")
val message = Text().apply {
text = "Hello, world. This is JavaFX from Kotlin."
fill = Color.DARKMAGENTA
font = Font.font("Serif", FontWeight.SEMI_BOLD, 32.0)
}
val messageWidth = message.layoutBounds.width
val messageHeight = message.layoutBounds.height
val group = Group(message)
group.layoutY = 80.0
group.layoutY = messageHeight * 2
val scene = Scene(group, 320.0, 160.0)
val scene = Scene(group, messageWidth, messageHeight * 3)
primaryStage?.scene = scene
primaryStage?.show()
TranslateTransition(Duration.seconds(8.0), message).apply {
fromX = 320.0
toX = -320.0
fromX = messageWidth
toX = -messageWidth
interpolator = Interpolator.LINEAR
cycleCount = TranslateTransition.INDEFINITE
}.play()
}
}
fun main(args: Array<String>) {
Application.launch(MessageBoard::class.java, *args)
}
}

他の形式にエクスポート: Unified diff