title: Padding in background
body: <p>I created this small example code in order to represent the problem that I face:</p>
  
  <pre><code>package test.barimages;
  
  import javafx.application.Application;
  import static javafx.application.Application.launch;
  import javafx.beans.property.ObjectProperty;
  import javafx.beans.property.SimpleObjectProperty;
  import javafx.geometry.Insets;
  import javafx.scene.Scene;
  import javafx.scene.control.ContentDisplay;
  import javafx.scene.control.Label;
  import javafx.scene.image.Image;
  import javafx.scene.image.ImageView;
  import javafx.scene.layout.FlowPane;
  import javafx.scene.text.Font;
  import javafx.stage.Stage;
  
  public class MainApp extends Application
  {
      ObjectProperty&lt;Label&gt; selectedText = new SimpleObjectProperty&lt;&gt;();
  
      @Override
      public void start(Stage stage) throws Exception
      {
          selectedText.addListener((obs, oldSelectedText, newSelectedText) -&gt;
          {
              if (oldSelectedText != null)
              {
                  oldSelectedText.setStyle("");
              }
              if (newSelectedText != null)
              {
                  newSelectedText.setStyle("-fx-background-color: lightgray; -fx-padding: 5;");
              }
          });
  
          FlowPane navigationBar = new FlowPane();
          navigationBar.setMaxHeight(45);
          navigationBar.setPadding(new Insets(5, 5, 5, 5));
          navigationBar.setVgap(10);   // Set vertical gap size
          navigationBar.setHgap(10);
  
          Label FirstIcon = FirstIcon();
          Label SecIcon = SecIcon();
          Label ThurIcon = ThurIcon();
  
          selectedText.set(FirstIcon);
  
          navigationBar.getChildren().addAll(FirstIcon, SecIcon, ThurIcon);
  
          Scene scene = new Scene(navigationBar);
  
          stage.setTitle("JavaFX and Maven");
          stage.setScene(scene);
          stage.show();
      }
  
      public static void main(String[] args)
      {
          launch(args);
      }
  
      private Label FirstIcon()
      {
          Image image = new Image("http://goo.gl/kYEQl");
          ImageView imageView = new ImageView();
          imageView.setImage(image);
  
          Label label = new Label("First");
          label.setFont(Font.font("Verdana", 12));
          label.setContentDisplay(ContentDisplay.LEFT);
  
          label.setGraphicTextGap(8);
  
          imageView.setFitWidth(40);
          imageView.setFitHeight(40);
          imageView.setPreserveRatio(true);
          imageView.setSmooth(true);
          imageView.setCache(true);
  
          label.setGraphic(imageView);
  
          label.setOnMouseClicked((event) -&gt;
          {
              selectedText.set(label);
          });
  
          return label;
      }
  
      private Label SecIcon()
      {
          Image image = new Image("http://goo.gl/kYEQl");
          ImageView imageView = new ImageView();
          imageView.setImage(image);
  
          Label label = new Label("Second");
          label.setFont(Font.font("Verdana", 12));
          label.setContentDisplay(ContentDisplay.LEFT);
  
          label.setGraphicTextGap(8);
  
          imageView.setFitWidth(40);
          imageView.setFitHeight(40);
          imageView.setPreserveRatio(true);
          imageView.setSmooth(true);
          imageView.setCache(true);
  
          label.setGraphic(imageView);
  
          label.setOnMouseClicked((event) -&gt;
          {
              selectedText.set(label);
          });
  
          return label;
      }
  
      private Label ThurIcon()
      {
          Image image = new Image("http://goo.gl/kYEQl");
          ImageView imageView = new ImageView();
          imageView.setImage(image);
  
          Label label = new Label("Thurd");
          label.setFont(Font.font("Verdana", 12));
          label.setContentDisplay(ContentDisplay.LEFT);
  
          label.setGraphicTextGap(8);
  
          imageView.setFitWidth(40);
          imageView.setFitHeight(40);
          imageView.setPreserveRatio(true);
          imageView.setSmooth(true);
          imageView.setCache(true);
  
          label.setGraphic(imageView);
  
          label.setOnMouseClicked((event) -&gt;
          {
              selectedText.set(label);
          });
  
          return label;
      }
  }
  </code></pre>
  
  <p>When you run the code and you click over the images you will see that selected Label pushes the next one. This is caused by the padding. Is there any way to preserve the background adding without pushing the near images?</p>