-
Bug
-
Resolution: Fixed
-
P2
-
8, 9
-
9, b136
-
linux
Secondary scene returns incorrect coordinates.
The sample below returns something like
x: 974.5
y: 369.33334362506866
x: 65.0
y: 24.0
At the same an actual window position is correct.
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class App extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
class MyDialog extends Stage {
public MyDialog(Stage parent) {
// initOwner(parent);
// initModality(Modality.WINDOW_MODAL);
setScene(new Scene(new Label("Label")));
sizeToScene();
}
}
Button button = new Button("Show Dialog");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
final Stage dlg = new MyDialog(primaryStage);
dlg.xProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
System.out.println("x: " + newValue);
}
});
dlg.yProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
System.out.println("y: " + newValue);
}
});
dlg.showAndWait();
}
});
primaryStage.setScene(new Scene(button));
primaryStage.show();
}
}
The sample below returns something like
x: 974.5
y: 369.33334362506866
x: 65.0
y: 24.0
At the same an actual window position is correct.
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class App extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
class MyDialog extends Stage {
public MyDialog(Stage parent) {
// initOwner(parent);
// initModality(Modality.WINDOW_MODAL);
setScene(new Scene(new Label("Label")));
sizeToScene();
}
}
Button button = new Button("Show Dialog");
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
final Stage dlg = new MyDialog(primaryStage);
dlg.xProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
System.out.println("x: " + newValue);
}
});
dlg.yProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
System.out.println("y: " + newValue);
}
});
dlg.showAndWait();
}
});
primaryStage.setScene(new Scene(button));
primaryStage.show();
}
}
- duplicates
-
JDK-8089784 [Linux] Stage x and y properties do not always match initial position for secondary stage
-
- Open
-