I do not like much working with the SceneBuilder (call me old fashioned)
I originally want to make a small application to train for exam questions: a toolbar like control with a left button for Previous question and a right button for the next question, while in the middle the question number.
Here is my solution proposal:
padding is set to 1 (using a black theme, it will allow a small while line around the pane :))
I specify the top margin for the buttons to 5 allowing the button to be centered on the text whose font size is bigger (14 instead of 12).
private BorderPane CreateWorkAreaToolbar()
{
btnPrevious = new Button( "Previous" );
btnPrevious.setOnAction( event -> OnPrevious( event ) );
btnPrevious.setFont( Font.font( btnPrevious.getFont().getName() , FontWeight.BOLD , FontPosture.ITALIC , 12 ) );
btnPrevious.setTextFill( Color.DARKRED );
btnPrevious.setPrefWidth( 80 );
lblProblemIdentifier = new Label( "ЧАСТЬ. - Задания № " );
lblProblemIdentifier.setFont(
Font.font( lblProblemIdentifier.getFont().getName() , FontWeight.BOLD , FontPosture.REGULAR , 14 ) );
lblProblemIdentifier.setTextAlignment( TextAlignment.CENTER );
btnNext = new Button( "Next" );
btnNext.setOnAction( event -> OnNext( event ) );
btnNext.setFont( Font.font( btnNext.getFont().getName() , FontWeight.BOLD , FontPosture.ITALIC , 12 ) );
btnNext.setTextFill( Color.BLUE );
btnNext.setPrefWidth( 80 );
BorderPane maintb = new BorderPane();
BorderPane.setMargin( btnNext , new Insets( 5.0 , 0.0 , 0.0 , 0.0 ) );
BorderPane.setMargin( btnPrevious , new Insets( 5.0 , 0.0 , 0.0 , 0.0 ) );
maintb.setPadding( new Insets( 1.0 , 10.0 , 1.0 , 10.0 ) );
maintb.setLeft( btnPrevious );
maintb.setCenter( lblProblemIdentifier );
maintb.setRight( btnNext );
maintb.getStylesheets().add( getClass().getResource( "style.css" ).toExternalForm() );
maintb.setPrefHeight( 44 );
return maintb;
}