When I run the following program, there is a 50% chance that the first click on the button will cause the window to be moved 10 pixels lower (using Ubuntu linux, Oracle JDK 1.8, JavaFx 8.0.102-b14). After that, each click correctly leads to a slight shift up.
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.stage.Stage; public class JavaFxTest extends Application { @Override public void start(Stage myStage) { myStage.setTitle("Hello World!"); Button myButton = new Button(); myButton.setText("Click!"); myButton.setOnAction(event -> myStage.setY(myStage.getY() - 1)); StackPane myStackPane = new StackPane(); myStackPane.getChildren().add(myButton); myStage.setScene(new Scene(myStackPane, 300, 250)); myStage.show(); } public static void main(String[] args) { launch(args); } }
The error is shown in the following video: https://youtu.be/c7QFuya7V4M
With awt and swing, I ran into similar problems and posted a question here: Workaround for bug_id = 4806603 regarding getBounds () and setBounds () on Linux?
Does anyone have a workaround to properly position the window?
java linux javafx-8
datahaki
source share