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

[Tab] TAB_CLOSE_REQUEST_EVENT is not propagated to the tab content

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Labels:
    • Environment:

      jdk1.8.0b75

      Description

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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported: