There is a very strange effect that padding value set for dialog pane is increased on the right side of the dialog every time when focus is changed from one control to the other. This is happening only with JDK 8u40 while with JDK 8u25 and openjfx-dialogs-1.0.2 works fine.
Next code example can reproduce this issue, when dialog is opened and focus is changed from text field to button and vice versa.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
class MyDialog extends Dialog {
public MyDialog() {
HBox hBox = new HBox(6);
hBox.getChildren().addAll(new TextField(), new Button("Button"));
getDialogPane().setContent(hBox);
getDialogPane().setStyle("-fx-padding: 1;");
getDialogPane().getButtonTypes().add(ButtonType.OK);
}
}
@Override
public void start(Stage primaryStage) throws Exception{
Button btn = new Button("Show dialog");
btn.setOnAction(e -> {
MyDialog dialog = new MyDialog();
dialog.showAndWait();
});
BorderPane root = new BorderPane(btn);
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Next code example can reproduce this issue, when dialog is opened and focus is changed from text field to button and vice versa.
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Main extends Application {
class MyDialog extends Dialog {
public MyDialog() {
HBox hBox = new HBox(6);
hBox.getChildren().addAll(new TextField(), new Button("Button"));
getDialogPane().setContent(hBox);
getDialogPane().setStyle("-fx-padding: 1;");
getDialogPane().getButtonTypes().add(ButtonType.OK);
}
}
@Override
public void start(Stage primaryStage) throws Exception{
Button btn = new Button("Show dialog");
btn.setOnAction(e -> {
MyDialog dialog = new MyDialog();
dialog.showAndWait();
});
BorderPane root = new BorderPane(btn);
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}