If you have a button with no text and just a node added using setGraphic, I would hope it would be vertically aligned. It isn't at the moment. If you look at the attached image, you will see that there is an extra pixel at the bottom of the button compared to the top. The button should be 1 pixel less in height.
Here is the code to reproduce:
package test;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class ButtonTest extends Application {
@Override
public void start(Stage stage) throws Exception {
BorderPane layout = new BorderPane();
Scene scene = new Scene(layout, 400, 400);
stage.setScene(scene);
Rectangle rectangle = new Rectangle(30,30);
Button button = new Button();
button.setGraphic(rectangle);
layout.setTop(button);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Here is the code to reproduce:
package test;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
public class ButtonTest extends Application {
@Override
public void start(Stage stage) throws Exception {
BorderPane layout = new BorderPane();
Scene scene = new Scene(layout, 400, 400);
stage.setScene(scene);
Rectangle rectangle = new Rectangle(30,30);
Button button = new Button();
button.setGraphic(rectangle);
layout.setTop(button);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
- is blocked by
-
JDK-8115125 Text not centered vertically in bounds for windows default 12px
- Resolved