I am trying to add event handler to the stage's title bar, but it won't work.
I tried using this:
primaryStage.addEVentHandler(MouseEvent.MOUSE_PRESSED, (event)->{
System.out.println("ok");
});
But it only register the event to the scene's area and won't read the mouse pressed event on the title bar.
Is there a way to listen the mouse event on stage's title bar?
Complete code:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class demo extends Application {
@Override
public void start(final Stage primaryStage) {
HBox box = new HBox();
Scene scene = new Scene(box, 350, 250);
Text text = new Text("Test");
box.getChildren().add(text);
primaryStage.addEventHandler(MouseEvent.MOUSE_PRESSED,(event) -> {
System.out.println("ok");
});
primaryStage.setScene(scene);
primaryStage.setTitle("TimePicker");
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}