The code shown below adds a couple of buttons to a HBox. The HBox spacing is set to 10 (which I presume means pixels but the java doc doesn't actually say that).
On Windows 7 I have the size of my text at 100% (default). Looking at the application there is a 10 pixel gap between the buttons which is what is expected.
Now I change my settings in Windows 7 so the size of my text is at 150% (the highest available to me) and run the program again. The font has increased in size and the buttons seem to have scaled well but the gap remains at 10 pixels. I took screen shots in both cases which can be seen here:
https://i.stack.imgur.com/35sCM.png
I would expect the gap to increase to 15 pixels.
Also notice that the scene has the same problem. It was defined as 500 by 500 but is the same size in both cases.
The documentation on all of this is very limited but from what I had read, I knew this didn't work with old versions of JavaFX but now that I am using the latest, JDK 8 update 20 I thought this would be "fixed" (if indeed this is the expected behaviour). I know I can style the spacing with em in a css file and then the spacing would increase with default text size but I just presumed the pixels would be scaled.
Does that mean on a retina display (on a mac book pro) the gap will stay at 10 pixels rather than 2x (i.e. 20 pixels)? I don't have one handy to test.
Please can someone explain whether this is all meant to work and just broken or it is never intended to work this way and so I will have to define the whole thing in em units.
Could someone with a macbook pro post a screen shot of this running in 2x mode?
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class JavaFXDPITest extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane pane = new BorderPane();
Scene scene = new Scene(pane, 500, 500);
primaryStage.setScene(scene);
HBox buttons = new HBox(10.0);
Button button1 = new Button("Button 1");
Button button2 = new Button("Button 2");
buttons.getChildren().addAll(button1, button2);
pane.setCenter(buttons);
pane.setRight(new Button("Focus Button"));
primaryStage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}