Java examples for JavaFX:TabPane
active JavaFX Tab
/**/*from www . ja v a 2 s . c om*/ * Author: obullxl@gmail.com * Copyright (c) 2004-2013 All Rights Reserved. */ //package com.java2s; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; public class Main { public static void activeTab(TabPane tabpane, Object userData) { if (userData == null) { return; } Tab tab = findTab(tabpane, userData); if (tab == null) { // ????Tab?? return; } if (!tab.isSelected()) { // ?? tabpane.getSelectionModel().select(tab); } } public static Tab findTab(TabPane tabpane, Object userData) { if (userData == null) { return null; } if (tabpane == null) { return null; } for (Tab tab : tabpane.getTabs()) { Object tabUserData = findTabUserData(tab); if (tabUserData == null) { return null; } if (userData.equals(tabUserData)) { return tab; } } return null; } @SuppressWarnings("unchecked") public static <T> T findTabUserData(Tab tab) { if (tab == null) { return null; } Object object = tab.getUserData(); if (object == null) { return null; } return (T) object; } }