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

[Tab] TAB_CLOSE_REQUEST_EVENT is not propagated to the tab content

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 8
    • 8
    • javafx
    • jdk1.8.0b75

      To reproduce close the tab.

      import javafx.application.Application;
      import javafx.event.Event;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.Tab;
      import javafx.scene.control.TabPane;
      import javafx.scene.layout.HBox;
      import javafx.stage.Stage;

      public class TabPaneVetoTest extends Application {

          TabPane testedControl;

          @Override
          public void start(Stage stage) {

              initTestedControl();

              HBox root = new HBox(20d);
              root.getChildren().add(testedControl);

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

              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);
          }

          private void initTestedControl() {
              testedControl = new TabPane();
              Tab tab = new Tab("Vetoing tab");
              tab.setClosable(true);
              
              Label lbl = new Label("Content");
              lbl.addEventHandler(Tab.TAB_CLOSE_REQUEST_EVENT, new EventHandler<Event>() {
                  @Override
                  public void handle(Event t) {
                      System.out.println("t = " + t);
                      t.consume();
                  }
              });

              tab.setContent(lbl);

              testedControl.getTabs().add(tab);
              testedControl.setMinSize(200.0, 100.0);
          }
      }

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

              Created:
              Updated:
              Resolved:
              Imported: