Package javafx.scene.control

Examples of javafx.scene.control.TabPane


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

        /*
         * Tabpane section
         */
        TabPane tabPane = new TabPane();
        tabPane.setPrefWidth(218);
        AquaFx.createTabPaneStyler().setType(TabPaneType.SMALL_ICON_BUTTONS).style(tabPane);

        Tab tab1 = new Tab();
        Image image = new Image(AquaFx.class.getResource("demo/images/pages/pages.png").toExternalForm());
        ImageView pages = new ImageView(image);
        pages.setPreserveRatio(true);
        pages.setFitHeight(16);
        tab1.setGraphic(pages);
        Label label = new Label("Dokument...");
        label.setPadding(new Insets(15));
        tab1.setContent(label);
        tabPane.getTabs().add(tab1);

        Tab tab2 = new Tab();
        Image image2 = new Image(AquaFx.class.getResource("demo/images/pages/layout.png").toExternalForm());
        ImageView layout = new ImageView(image2);
        layout.setPreserveRatio(true);
        layout.setFitHeight(16);
        tab2.setGraphic(layout);
        Label label2 = new Label("layout");
        label2.setPadding(new Insets(15));
        tab2.setContent(label2);
        tabPane.getTabs().add(tab2);

        Tab tab3 = new Tab();
        Image image3 = new Image(AquaFx.class.getResource("demo/images/pages/umbruch.png").toExternalForm());
        ImageView umbruch = new ImageView(image3);
        umbruch.setPreserveRatio(true);
        umbruch.setFitHeight(16);
        tab3.setGraphic(umbruch);
        Label label3 = new Label("Zeilenumbruch...");
        label3.setPadding(new Insets(15));
        tab3.setContent(label3);
        tabPane.getTabs().add(tab3);

        Tab tab4 = new Tab();
        Image image4 = new Image(AquaFx.class.getResource("demo/images/pages/text.png").toExternalForm());
        ImageView text = new ImageView(image4);
        text.setPreserveRatio(true);
        text.setFitHeight(16);
        tab4.setGraphic(text);
        Label label4 = new Label("Zeilenumbruch...");
        label4.setPadding(new Insets(15));
        tab4.setContent(label4);
        tabPane.getTabs().add(tab4);

        Tab tab5 = new Tab();
        Image image5 = new Image(AquaFx.class.getResource("demo/images/pages/grafik.png").toExternalForm());
        ImageView grafik = new ImageView(image5);
        grafik.setPreserveRatio(true);
        grafik.setFitHeight(16);
        tab5.setGraphic(grafik);
        Label label5 = new Label("Zeilenumbruch...");
        label5.setPadding(new Insets(15));
        tab5.setContent(label5);
        tabPane.getTabs().add(tab5);

        Tab tab6 = new Tab();
        Image image6 = new Image(AquaFx.class.getResource("demo/images/pages/lineal.png").toExternalForm());
        ImageView lineal = new ImageView(image6);
        lineal.setPreserveRatio(true);
        lineal.setFitHeight(16);
        tab6.setGraphic(lineal);
        Label label6 = new Label("Lienal lineal lineal lineal lineal...");
        label6.setPadding(new Insets(15));
        tab6.setContent(label6);
        tabPane.getTabs().add(tab6);

        Tab tab7 = new Tab();
        Image image7 = new Image(AquaFx.class.getResource("demo/images/pages/diagramm.png").toExternalForm());
        ImageView diagramm = new ImageView(image7);
        diagramm.setPreserveRatio(true);
        diagramm.setFitHeight(16);
        tab7.setGraphic(diagramm);
        Label label7 = new Label("diagramm...");
        label7.setPadding(new Insets(15));
        tab7.setContent(label7);
        tabPane.getTabs().add(tab7);

        Tab tab8 = new Tab();
        Image image8 = new Image(AquaFx.class.getResource("demo/images/pages/verknuepfung.png").toExternalForm());
        ImageView verknuepfung = new ImageView(image8);
        verknuepfung.setPreserveRatio(true);
        verknuepfung.setFitHeight(16);
        tab8.setGraphic(verknuepfung);
        Label label8 = new Label("verknuepfung...");
        label8.setPadding(new Insets(15));
        tab8.setContent(label8);
        tabPane.getTabs().add(tab8);

        Tab tab9 = new Tab();
        Image image9 = new Image(AquaFx.class.getResource("demo/images/pages/quicktime.png").toExternalForm());
        ImageView quicktime = new ImageView(image9);
        quicktime.setPreserveRatio(true);
        quicktime.setFitHeight(16);
        tab9.setGraphic(quicktime);
        Label label9 = new Label("quicktime...");
        label9.setPadding(new Insets(15));
        tab9.setContent(label9);
        tabPane.getTabs().add(tab9);

        root.getChildren().add(tabPane);

        AquaFx.style();
        stage.setScene(scene);
View Full Code Here


        stage.show();
    }

    public Node getContent(Scene scene) {
        // TabPane
        final TabPane tabPane = new TabPane();
        tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
        tabPane.setPrefWidth(scene.getWidth());
        tabPane.setPrefHeight(scene.getHeight());

        tabPane.prefWidthProperty().bind(scene.widthProperty());
        tabPane.prefHeightProperty().bind(scene.heightProperty());

        // list view examples
        Tab listViewTab = new Tab("ListView");
        buildListViewTab(listViewTab);
        tabPane.getTabs().add(listViewTab);

        // tree view examples
        Tab treeViewTab = new Tab("TreeView");
        buildTreeViewTab(treeViewTab);
        tabPane.getTabs().add(treeViewTab);

        // table view examples
        Tab tableViewTab = new Tab("TableView");
        buildTableViewTab(tableViewTab);
        tabPane.getTabs().add(tableViewTab);

        return tabPane;
    }
View Full Code Here

    @Override
    public void start(Stage primaryStage) throws Exception {
        BorderPane pane = new BorderPane();
        
        TabPane tabPane = new TabPane();
        Tab tab1 = new Tab("Tab 1 (disabled)");
        tab1.setContent(new Label("Lorem Ipsum tab1"));
        tab1.setDisable(true);
        tabPane.getTabs().add(tab1);
        final Tab tab2 = new Tab("Tab 2");
        tab2.setContent(new Label("Lorem Ipsum"));
        tabPane.getTabs().add(tab2);
        pane.setTop(tabPane);
        
        Button btn = new Button("disable/enable Tab 2");
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
View Full Code Here

        Scene scene = new Scene(root);

        /*
         * Tabpane section
         */
        TabPane tabPane = new TabPane();
        AquaFx.createTabPaneStyler().setType(TabPaneType.ICON_BUTTONS).style(tabPane);

        Tab tab1 = new Tab("Allgemein");
        Image image = new Image(AquaFx.class.getResource("demo/images/preferences/allgemein.png").toExternalForm());
        ImageView pages = new ImageView(image);
        pages.setPreserveRatio(true);
        pages.setFitHeight(36);
        tab1.setGraphic(pages);
        Label label =new Label("Allgemein...");
        label.setPadding(new Insets(15));
        tab1.setContent(label);
        tabPane.getTabs().add(tab1);

        Tab tab2 = new Tab("Etiketten");
        Image image2 = new Image(AquaFx.class.getResource("demo/images/preferences/labels.png").toExternalForm());
        ImageView layout =  new ImageView(image2);
        layout.setPreserveRatio(true);
        layout.setFitHeight(36);
        tab2.setGraphic(layout);
        Label label2 = new Label("Etiketten");
        label2.setPadding(new Insets(15));
        tab2.setContent(label2);
        tabPane.getTabs().add(tab2);

        Tab tab3 = new Tab("Seitenleiste");
        Image image3 = new Image(AquaFx.class.getResource("demo/images/preferences/seitenleiste.png").toExternalForm());
        ImageView umbruch = new ImageView(image3);
        umbruch.setPreserveRatio(true);
        umbruch.setFitHeight(36);
        tab3.setGraphic(umbruch);
        Label label3 = new Label("seitenleiste...");
        label3.setPadding(new Insets(15));
        tab3.setContent(label3);
        tabPane.getTabs().add(tab3);

        Tab tab4 = new Tab("Erweitert");
        Image image4 = new Image(AquaFx.class.getResource("demo/images/preferences/einstellungen.png").toExternalForm());
        ImageView text = new ImageView(image4);
        text.setPreserveRatio(true);
        text.setFitHeight(36);
        tab4.setGraphic(text);

        VBox vbox = new VBox();
        vbox.setPadding(new Insets(20, 20, 18, 20));
        vbox.setSpacing(8);

        CheckBox box1 = new CheckBox("Alle Dateinamensuffixe einblenden");
        CheckBox box2 = new CheckBox("Vor dem \u00C4ndern eines Suffixes nachfragen");
        box2.setSelected(true);
        CheckBox box3 = new CheckBox("Vor dem Entleeren des Papierkorbs nachfragen");
        box3.setSelected(true);
        CheckBox box4 = new CheckBox("Papierkorb sicher entleeren");

        Label info = new Label("Bei Suchvorg\u00E4ngen:");
        info.setPadding(new Insets(9, 0, 0, 0));

        ObservableList<String> items = FXCollections.observableArrayList("Diesen Mac durchsuchen", "Aktuellen Ordner durchsuchen",
                "Letzten Suchbereich verwenden");
        ChoiceBox<String> choice = new ChoiceBox<String>(items);
       
        choice.getSelectionModel().selectFirst();
        vbox.getChildren().addAll(box1, box2, box3, box4, info, choice);

        tab4.setContent(vbox);
        tabPane.getTabs().add(tab4);
        tabPane.getSelectionModel().selectLast();
        root.getChildren().add(tabPane);

        AquaFx.style();
        stage.setScene(scene);
        stage.show();
View Full Code Here

        Scene scene = new Scene(root, 300, 210);
        AquaFx.style();
        stage.setScene(scene);
        stage.setTitle("TabPaneDemo");

        TabPane tabPane = new TabPane();
        tabPane.setSide(Side.TOP);
        tabPane.setPadding(new Insets(15));

        // Create Tabs
        Tab tabD = new Tab();
        tabD.setText("tab 1");

        VBox box = new VBox();
        box.setSpacing(15);
        box.setPadding(new Insets(15));
        Button b1 = new Button("regular");
        box.getChildren().add(b1);
        Button b3 = new Button("round rect");
        AquaFx.createButtonStyler().setType(ButtonType.ROUND_RECT).style(b3);
        box.getChildren().add(b3);

        tabD.setContent(box);

        tabPane.getTabs().add(tabD);

        Tab tabE = new Tab();
        tabE.setText("tab 2");
        tabPane.getTabs().add(tabE);

        Tab tabF = new Tab();
        tabF.setText("tab 3");
        tabPane.getTabs().add(tabF);

        scene.setRoot(tabPane);
        stage.show();
    }
View Full Code Here

        final Map<Tab, Timeline> closedTab = new HashMap<Tab, Timeline>();
        getSkinnable().getTabs().addListener(new ListChangeListener<Tab>() {
            @Override public void onChanged(final Change<? extends Tab> c) {     
                while (c.next()) {
                    if (c.wasPermutated()) {
                        TabPane tabPane = getSkinnable();
                        List<Tab> tabs = tabPane.getTabs();
                        // tabs sorted : create list of permutated tabs.
                        // clear selection, set tab animation to NONE
                        // remove permutated tabs, add them back in correct order.
                        // restore old selection, and old tab animation states.
                        int size = c.getTo() - c.getFrom();
                        Tab selTab = tabPane.getSelectionModel().getSelectedItem();
                        List<Tab> permutatedTabs = new ArrayList<Tab>(size);
                        getSkinnable().getSelectionModel().clearSelection();
                        // save and set tab animation to none - as it is not a good idea
                        // to animate on the same data for open and close.
                        TabAnimation prevOpenAnimation = openTabAnimation.get();
View Full Code Here

        return tabHeaderArea.getBaselineOffset() + tabHeaderArea.getLayoutY();
    }

    @Override protected void layoutChildren(final double x, final double y,
            final double w, final double h) {
        TabPane tabPane = getSkinnable();
        Side tabPosition = tabPane.getSide();

        double headerHeight = snapSize(tabHeaderArea.prefHeight(-1));
        double tabsStartX = tabPosition.equals(Side.RIGHT)? x + w - headerHeight : x;
        double tabsStartY = tabPosition.equals(Side.BOTTOM)? y + h - headerHeight : y;
View Full Code Here

        }
        private Point2D dragAnchor;
        public TabHeaderArea() {
            getStyleClass().setAll("tab-header-area");
            setManaged(false);
            final TabPane tabPane = getSkinnable();

            headerClip = new Rectangle();
           
            headersRegion = new StackPane() {
                @Override protected double computePrefWidth(double height) {
                    double width = 0.0F;
                    for (Node child : getChildren()) {
                        TabHeaderSkin tabHeaderSkin = (TabHeaderSkin)child;
                        if (tabHeaderSkin.isVisible()) {
                            width += tabHeaderSkin.prefWidth(height);
                        }
                    }
                    return snapSize(width) + snappedLeftInset() + snappedRightInset();
                }

                @Override protected double computePrefHeight(double width) {
                    double height = 0.0F;
                    for (Node child : getChildren()) {
                        TabHeaderSkin tabHeaderSkin = (TabHeaderSkin)child;
                        height = Math.max(height, tabHeaderSkin.prefHeight(width));
                    }
                    return snapSize(height) + snappedTopInset() + snappedBottomInset();
                }

                @Override protected void layoutChildren() {
                    if (tabsFit()) {
                        setScrollOffset(0.0);
                    } else {
                        if (!removeTab.isEmpty()) {                           
                            double offset = 0;
                            double w = tabHeaderArea.getWidth() - snapSize(controlButtons.prefWidth(-1)) - firstTabIndent() - SPACER;
                            Iterator i = getChildren().iterator();
                            while (i.hasNext()) {
                                TabHeaderSkin tabHeader = (TabHeaderSkin)i.next();
                                double tabHeaderPrefWidth = snapSize(tabHeader.prefWidth(-1));
                                if (removeTab.contains(tabHeader)) {                                   
                                    if (offset < w) {
                                        isSelectingTab = true;
                                    }
                                    i.remove();
                                    removeTab.remove(tabHeader);
                                    if (removeTab.isEmpty()) {
                                        break;
                                    }
                                }
                                offset += tabHeaderPrefWidth;                               
                            }
                        } else {
                            isSelectingTab = true;
                        }
                    }

                    if (isSelectingTab) {
                        double offset = 0;
                        double selectedTabOffset = 0;
                        double selectedTabWidth = 0;
                        double previousSelectedTabOffset = 0;
                        double previousSelectedTabWidth = 0;
                        for (Node node: getChildren()) {
                            TabHeaderSkin tabHeader = (TabHeaderSkin)node;
                            // size and position the header relative to the other headers
                            double tabHeaderPrefWidth = snapSize(tabHeader.prefWidth(-1));
                            if (selectedTab != null && selectedTab.equals(tabHeader.getTab())) {
                                selectedTabOffset = offset;
                                selectedTabWidth = tabHeaderPrefWidth;
                            }
                            if (previousSelectedTab != null && previousSelectedTab.equals(tabHeader.getTab())) {
                                previousSelectedTabOffset = offset;
                                previousSelectedTabWidth = tabHeaderPrefWidth;
                            }
                            offset+=tabHeaderPrefWidth;
                        }
                        if (selectedTabOffset > previousSelectedTabOffset) {
                            scrollToSelectedTab(selectedTabOffset + selectedTabWidth, previousSelectedTabOffset);
                        } else {
                            scrollToSelectedTab(selectedTabOffset, previousSelectedTabOffset);
                        }
                        isSelectingTab = false;
                    }

                    Side tabPosition = getSkinnable().getSide();
                    double tabBackgroundHeight = snapSize(prefHeight(-1));
                    double tabX = (tabPosition.equals(Side.LEFT) || tabPosition.equals(Side.BOTTOM)) ?
                        snapSize(getWidth()) - getScrollOffset() : getScrollOffset();

                    updateHeaderClip();
                    for (Node node : getChildren()) {
                        TabHeaderSkin tabHeader = (TabHeaderSkin)node;
                        // size and position the header relative to the other headers
                        double tabHeaderPrefWidth = snapSize(tabHeader.prefWidth(-1));
                        double tabHeaderPrefHeight = snapSize(tabHeader.prefHeight(-1));
                        tabHeader.resize(tabHeaderPrefWidth, tabHeaderPrefHeight);
                        // This ensures that the tabs are located in the correct position
                        // when there are tabs of differing heights.
                        double startY = tabPosition.equals(Side.BOTTOM) ?
                            0 : tabBackgroundHeight - tabHeaderPrefHeight - snappedBottomInset();
                        if (tabPosition.equals(Side.LEFT) || tabPosition.equals(Side.BOTTOM)) {
                            // build from the right
                            tabX -= tabHeaderPrefWidth;
                            tabHeader.relocate(tabX, startY);
                        } else {
                            // build from the left
                            tabHeader.relocate(tabX, startY);
                            tabX += tabHeaderPrefWidth;
                        }
                    }
                }
            };
            headersRegion.getStyleClass().setAll("headers-region");
            headersRegion.setClip(headerClip);

            headerBackground = new StackPane();
            headerBackground.getStyleClass().setAll("tab-header-background");

            int i = 0;
            for (Tab tab: tabPane.getTabs()) {
                addTab(tab, i++, true);
            }

            controlButtons = new TabControlButtons();
            controlButtons.setVisible(false);
View Full Code Here

            focusIndicator.setMouseTransparent(true);
            focusIndicator.getStyleClass().add("focus-indicator");
           
            inner = new StackPane() {
                @Override protected void layoutChildren() {
                    final TabPane skinnable = getSkinnable();
                   
                    final double paddingTop = snappedTopInset();
                    final double paddingRight = snappedRightInset();
                    final double paddingBottom = snappedBottomInset();
                    final double paddingLeft = snappedLeftInset();
                    final double w = getWidth() - (paddingLeft + paddingRight);
                    final double h = getHeight() - (paddingTop + paddingBottom);

                    final double prefLabelWidth = snapSize(label.prefWidth(-1));
                    final double prefLabelHeight = snapSize(label.prefHeight(-1));
                   
                    final double closeBtnWidth = showCloseButton() ? snapSize(closeBtn.prefWidth(-1)) : 0;
                    final double closeBtnHeight = showCloseButton() ? snapSize(closeBtn.prefHeight(-1)) : 0;
                    final double minWidth = snapSize(skinnable.getTabMinWidth());
                    final double maxWidth = snapSize(skinnable.getTabMaxWidth());
                    final double minHeight = snapSize(skinnable.getTabMinHeight());
                    final double maxHeight = snapSize(skinnable.getTabMaxHeight());

                    double labelAreaWidth = prefLabelWidth;
                    double labelAreaHeight = prefLabelHeight;
                    double labelWidth = prefLabelWidth;
                    double labelHeight = prefLabelHeight;
View Full Code Here

        private ContextMenu popup;

        public TabControlButtons() {           
            getStyleClass().setAll("control-buttons-tab");

            TabPane tabPane = getSkinnable();

            downArrowBtn = new Pane();
            downArrowBtn.getStyleClass().setAll("tab-down-button");
            downArrowBtn.setVisible(isShowTabsMenu());
            downArrow = new StackPane();
            downArrow.setManaged(false);
            downArrow.getStyleClass().setAll("arrow");
            downArrow.setRotate(tabPane.getSide().equals(Side.BOTTOM) ? 180.0F : 0.0F);
            downArrowBtn.getChildren().add(downArrow);
            downArrowBtn.setOnMouseClicked(new EventHandler<MouseEvent>() {
                @Override public void handle(MouseEvent me) {
                    showPopupMenu();
                }
            });
           
            setupPopupMenu();

            inner = new StackPane() {
                private double getArrowBtnWidth() {
                    if (animationLock) return maxArrowWidth;
                    if (isShowTabsMenu()) {
                        maxArrowWidth = Math.max(maxArrowWidth, snapSize(downArrow.prefWidth(getHeight())) + snapSize(downArrowBtn.prefWidth(getHeight())));
                    }
                    return maxArrowWidth;
                }

                @Override protected double computePrefWidth(double height) {
                    if (animationLock) return innerPrefWidth;
                    innerPrefWidth = getActualPrefWidth();
                    return innerPrefWidth;
                }

                public double getActualPrefWidth() {
                    double pw;
                    double maxArrowWidth = getArrowBtnWidth();
                    pw = 0.0F;
                    if (isShowTabsMenu()) {
                        pw += maxArrowWidth;
                    }
                    if (pw > 0) {
                        pw += snappedLeftInset() + snappedRightInset();
                    }
                    return pw;
                }

                @Override protected double computePrefHeight(double width) {
                    double height = 0.0F;
                    if (isShowTabsMenu()) {
                        height = Math.max(height, snapSize(downArrowBtn.prefHeight(width)));
                    }
                    if (height > 0) {
                        height += snappedTopInset() + snappedBottomInset();
                    }
                    return height;
                }

                @Override protected void layoutChildren() {
                    Side tabPosition = getSkinnable().getSide();
                    double x = 0.0F;
                    //padding.left;
                    double y = snappedTopInset();
                    double h = snapSize(getHeight()) - y + snappedBottomInset();
                    // when on the left or bottom, we need to position the tabs controls
                    // button such that it is the furtherest button away from the tabs.
                    if (tabPosition.equals(Side.BOTTOM) || tabPosition.equals(Side.LEFT)) {
                        x += positionTabsMenu(x, y, h, true);
                    } else {
                        x += positionTabsMenu(x, y, h, false);
                    }
                }

                private double positionTabsMenu(double x, double y, double h, boolean showSep) {
                    double newX = x;
                    if (isShowTabsMenu()) {
                        // DOWN ARROW BUTTON
                        positionArrow(downArrowBtn, downArrow, newX, y, maxArrowWidth, h);
                        newX += maxArrowWidth;
                    }
                    return newX;
                }

                private void positionArrow(Pane btn, StackPane arrow, double x, double y, double width, double height) {
                    btn.resize(width, height);
                    positionInArea(btn, x, y, width, height, /*baseline ignored*/0,
                            HPos.CENTER, VPos.CENTER);
                    // center arrow region within arrow button
                    double arrowWidth = snapSize(arrow.prefWidth(-1));
                    double arrowHeight = snapSize(arrow.prefHeight(-1));
                    arrow.resize(arrowWidth, arrowHeight);
                    positionInArea(arrow, btn.snappedLeftInset(), btn.snappedTopInset(),
                            width - btn.snappedLeftInset() - btn.snappedRightInset(),
                            height - btn.snappedTopInset() - btn.snappedBottomInset(),
                            /*baseline ignored*/0, HPos.CENTER, VPos.CENTER);
                }
            };
            inner.getStyleClass().add("container");
            inner.getChildren().add(downArrowBtn);

            getChildren().add(inner);

            tabPane.sideProperty().addListener(new InvalidationListener() {
                @Override public void invalidated(Observable valueModel) {
                    Side tabPosition = getSkinnable().getSide();
                    downArrow.setRotate(tabPosition.equals(Side.BOTTOM)? 180.0F : 0.0F);
                }
            });
            tabPane.getTabs().addListener(new ListChangeListener<Tab>() {
                @Override public void onChanged(Change<? extends Tab> c) {
                    setupPopupMenu();
                }
            });
            showControlButtons = false;
View Full Code Here

TOP

Related Classes of javafx.scene.control.TabPane

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.