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

[TabPane] Disabled / Disable states are inconsistent

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 8
    • 8
    • javafx
    • jdk1.8.0_b64

    Description

      Please look at http://docs.oracle.com/javafx/2/api/javafx/scene/control/Tab.html#isDisabled();
      It says that when tab pane is disabled, method should return true, but it doesn't.

      To reproduce:
      1. Open app;
      2. Push the button;
      3. You will see that isDisabled() isn't 'true' for tabs in the disabled tab pane.

      import java.util.Iterator;
      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class JavaFXApplication62 extends Application {

          @Override
          public void start(Stage stage) {

              final TabPane tp1 = new TabPane();
              tp1.getTabs().addAll(new Tab("11"), new Tab("12"));
              
              Tab disabledTab = new Tab("Disabled");
              disabledTab.setDisable(true);
              tp1.getTabs().add(disabledTab);
               
              tp1.setStyle("-fx-border-color:GREEN");
              tp1.setMinWidth(150);
              tp1.setPrefWidth(150);
              tp1.setMaxWidth(150);
              tp1.setMinHeight(150);
              tp1.setPrefHeight(150);
              tp1.setMaxHeight(150);

              final TabPane tp2 = new TabPane();
              tp2.getTabs().addAll(new Tab("21"), new Tab("22"));
              
              Tab secondDisaTab = new Tab("Disabled - 2");
              secondDisaTab.setDisable(true);
              
              tp2.getTabs().add(secondDisaTab);
              
              tp2.setStyle("-fx-border-color:GREEN");
              tp2.setMinWidth(150);
              tp2.setPrefWidth(150);
              tp2.setMaxWidth(150);
              tp2.setMinHeight(150);
              tp2.setPrefHeight(150);
              tp2.setMaxHeight(150);
              tp2.setDisable(true);
                  
              HBox root = new HBox(20d);
              root.getChildren().addAll(tp1, tp2);

              Button btnShowProps = new Button("Show properties");
              btnShowProps.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent t) {
                      for(Iterator<Tab> it : new Iterator [] {
                                              tp1.getTabs().iterator(),
                                              tp2.getTabs().iterator()})
                      {
                          while(it.hasNext()) {
                              Tab tab = it.next();
                              System.out.println("Text = " + tab.getText());
                              System.out.println("isDisable() = " + tab.isDisable());
                              System.out.println("isDisabled() = " + tab.isDisabled());
                          }
                      }
                  }
              });

              root.getChildren().add(btnShowProps);

              Scene scene = new Scene(root, 400, 300);

              stage.setScene(scene);
              stage.setTitle(System.getProperty("java.runtime.version") + "; " + System.getProperty("javafx.runtime.version"));
              stage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            dzinkevi Dmitry Zinkevich (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: