Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152162

TabPane Padding is mostly ignored

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8u74
    • javafx
    • None

      In the test below padding for TabPane is set. Execute the test and change the tab side - as you can see tabs look correct for top side only. Other sides fail. The tab-header-area seems to ignore padding completely.

      tabPane.css:

      .tab-pane {
          -fx-padding: 20;
      }

      .tab-pane > .tab-header-area{
          -fx-background-color: cyan;
      }

      .tab-pane > .tab-content-area{
          -fx-background-color: yellow;
      }



      public class TabPaneTest extends Application
      {
        public static void main(String[] args)
        {
          Application.launch(args);
        }

        @Override
        public void start(Stage stage)
        {
          Parent root = createContentPane();
          root.getStylesheets().add(getClass().getResource("/test/tabpane/tabPane.css").toExternalForm());
          Scene scene = new Scene(root, 1000, 800);
          stage.setScene(scene);
          stage.setTitle(getClass().getSimpleName());
          stage.show();
        }

        private Parent createContentPane()
        {
          TabPane tabPane = new TabPane();
          tabPane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);
          
          tabPane.getTabs().add(createTab("Tab 1", new StackPane()));
          tabPane.getTabs().add(createTab("Tab 2", new StackPane()));
          tabPane.getTabs().add(createTab("Tab 3", new StackPane()));
          tabPane.getSelectionModel().selectLast();
          
          ComboBox<Side> combo = new ComboBox<>();
          combo.setItems(FXCollections.observableArrayList(Side.values()));
          combo.setValue(tabPane.getSide());
          combo.valueProperty().addListener((o, ov, nv) -> tabPane.setSide(nv));

          CheckBox cb = new CheckBox("Floating");
          cb.setSelected(true);
          cb.selectedProperty().addListener((o, ov, nv) -> {
            if (nv)
              tabPane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);
            else
              tabPane.getStyleClass().remove(TabPane.STYLE_CLASS_FLOATING);
          });
          
          VBox optionPane = new VBox(5);
          optionPane.getChildren().add(combo);
          optionPane.getChildren().add(cb);
          optionPane.setStyle("-fx-padding:5; -fx-background-color: #0001");
          
          BorderPane p = new BorderPane();
          p.setCenter(tabPane);
          p.setRight(optionPane);
          
          return p;
        }

        private Tab createTab(String name, Node content)
        {
          Tab tab = new Tab();
          tab.setText(name);
          tab.setContent(content);
          return tab;
        }
      }

            jgiles Jonathan Giles
            wzberger Wolfgang Zitzelsberger
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: