buttonsample2

 

スクリプト

buttonsample2.fx

import javafx.ext.swing.SwingButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.stage.Stage;
 
// ボタンに表示する文字列
var buttonText = "Initial";
 
Stage {
    title: "Button Sample"
    scene: Scene {
        width: 240
        height: 100
        content: [
                SwingButton {
                // 表示文字列は buttonText にバインドする
                text: bind buttonText
                width: 200
                height: 60
                translateX: 20
                translateY: 20
                font: Font {
                    size: 24
                }
                
                onMouseEntered: function(event: MouseEvent) {
                    buttonText = "Enter"
                }
                onMouseExited: function(event: MouseEvent) {
                    buttonText = "Exit"
                }
                onMousePressed: function(event: MouseEvent) {
                    buttonText = "Press"
                }
                onMouseReleased: function(event: MouseEvent) {
                    buttonText = "Release"
                }
            }

        ]

    }
}