build JavaFX Tab - Java JavaFX

Java examples for JavaFX:TabPane

Description

build JavaFX Tab

Demo Code


import javafx.collections.ObservableMap;
import javafx.scene.Node;
import javafx.scene.control.Tab;
import java.util.UUID;

public class Main{
    private static String TAB_DOCKABLE = PREFIX + "tab.dockable";
    public static final Tab buildTab(Dockable content) {
        Tab tab = new Tab(content.getTitle());
        tab.setContent(content.getContent());
        tab.getProperties().put(TAB_DOCKABLE, content);
        return tab;
    }/*from  w  w w  .j a  va2  s . c  o m*/
    /**
     * Get properties from known objects. Currently supported are Node, Tab
     * @param obj
     * @return object properties
     * @throws java.lang.IllegalArgumentException if object types is not supported
     */
    private static ObservableMap<Object, Object> getProperties(Object obj) {
        if (obj instanceof Node)
            ((Node) obj).getProperties();
        if (obj instanceof Tab)
            ((Tab) obj).getProperties();
        throw new IllegalArgumentException("Unknown object type: "
                + obj.getClass().getName());
    }
}

Related Tutorials