我有一个 JavaFX 应用程序,当应用程序在后台或最小化时,它需要监听 ctrl+space+T 以将应用程序窗口置于最前面。我可以知道是否有人有解决方案?
public class MainApp extends Application {
@Override
public void start(Stage primaryStage) {
primaryStage = setStagePositionToBottomRight(primaryStage);
loadAndStartMainScreen(primaryStage);
}
private void loadAndStartMainScreen(Stage primaryStage) {
MainViewController scenes = new MainViewController();
AnchorPane mainScene = scenes.getMainView();
Scene scene = new Scene(mainScene);
primaryStage.setScene(scene);
primaryStage.show();
}
private Stage setStagePositionToBottomRight(Stage primaryStage) {
final int coordinateX = 335;
final int coordinateY = 510;
Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
// primaryStage.initStyle(StageStyle.UNDECORATED);
primaryStage.setX(primaryScreenBounds.getMaxX() - coordinateX);
primaryStage.setY(primaryScreenBounds.getMaxY() - coordinateY);
return primaryStage;
}
public static void main(String[] args) {
launch(args);
}
}