如何在javafx场景构建器中选择选项卡时执行某些操作?

时间:2017-03-29 11:45:49

标签: java javafx fxml scenebuilder

这是我的布局fxml文件:

<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="443.0" prefWidth="610.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller">
   <children>
      <TabPane fx:id="tabPane" layoutY="37.0" nodeOrientation="RIGHT_TO_LEFT" onContextMenuRequested="#event" prefHeight="400.0" prefWidth="610.0" tabClosingPolicy="UNAVAILABLE">
        <tabs>
          <Tab fx:id="total" closable="false" text="x" onSelectionChanged="#event">
            <content>
              <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
            </content>
          </Tab>
          <Tab text="x">
            <content>
              <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
            </content>
          </Tab>
            <Tab text="y">
               <content>
                  <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
               </content>
            </Tab>
            <Tab text="y">
               <content>
                  <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
               </content>
            </Tab>
        </tabs>
      </TabPane>
   </children>
</Pane>

如果用户点击带有总ID的标签但是我使用onSelectionChanged并且无法帮助我,我想执行操作。如果用户点击总ID标签,我该如何处理?

1 个答案:

答案 0 :(得分:1)

请尝试以下代码;

([\d\w-]+.){6}hi