Package javafx.scene.control

Examples of javafx.scene.control.Tab


                }
            };
            closeBtn.getStyleClass().setAll("tab-close-button");
            closeBtn.setOnMousePressed(new EventHandler<MouseEvent>() {
                @Override public void handle(MouseEvent me) {
                    Tab tab = getTab();
                    TabPaneBehavior behavior = getBehavior();
                    if (behavior.canCloseTab(tab)) {
                         removeListeners(tab);
                         behavior.closeTab(tab);
                         setOnMousePressed(null);   
                    }
                }
            });
           
            updateGraphicRotation();

            final int padding = 2;
            final Region focusIndicator = new Region();
            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;
                   
                    final double childrenWidth = labelAreaWidth + closeBtnWidth;
                    final double childrenHeight = Math.max(labelAreaHeight, closeBtnHeight);
                   
                    if (childrenWidth > maxWidth && maxWidth != Double.MAX_VALUE) {
                        labelAreaWidth = maxWidth - closeBtnWidth;
                        labelWidth = maxWidth - closeBtnWidth;
                    } else if (childrenWidth < minWidth) {
                        labelAreaWidth = minWidth - closeBtnWidth;
                    }

                    if (childrenHeight > maxHeight && maxHeight != Double.MAX_VALUE) {
                        labelAreaHeight = maxHeight;
                        labelHeight = maxHeight;
                    } else if (childrenHeight < minHeight) {
                        labelAreaHeight = minHeight;
                    }

                    if (animating) {
                        if (prefWidth.getValue() < labelAreaWidth) {
                            labelAreaWidth = prefWidth.getValue();
                        }
                        closeBtn.setVisible(false);
                    } else {
                        closeBtn.setVisible(showCloseButton());
                    }
                   
                   
                    label.resize(labelWidth, labelHeight);
                   
                   
                    double labelStartX = paddingLeft;
                   
                    // If maxWidth is less than Double.MAX_VALUE, the user has
                    // clamped the max width, but we should
                    // position the close button at the end of the tab,
                    // which may not necessarily be the entire width of the
                    // provided max width.
                    double closeBtnStartX = (maxWidth < Double.MAX_VALUE ? Math.min(w, maxWidth) : w) - paddingRight - closeBtnWidth;
                   
                    positionInArea(label, labelStartX, paddingTop, labelAreaWidth, h,
                            /*baseline ignored*/0, HPos.CENTER, VPos.CENTER);

                    if (closeBtn.isVisible()) {
                        closeBtn.resize(closeBtnWidth, closeBtnHeight);
                        positionInArea(closeBtn, closeBtnStartX, paddingTop, closeBtnWidth, h,
                                /*baseline ignored*/0, HPos.CENTER, VPos.CENTER);
                    }
                   
                    focusIndicator.resizeRelocate(
                            label.getLayoutX() - padding,
                            Math.min(label.getLayoutY(), closeBtn.isVisible() ? closeBtn.getLayoutY() : Double.MAX_VALUE) - padding,
                            labelWidth + closeBtnWidth + padding * 2,
                            Math.max(labelHeight, closeBtnHeight) + padding*2);
                }
            };
            inner.getStyleClass().add("tab-container");
            inner.setRotate(getSkinnable().getSide().equals(Side.BOTTOM) ? 180.0F : 0.0F);
            inner.getChildren().addAll(label, closeBtn, focusIndicator);

            getChildren().addAll(inner);

            tooltip = tab.getTooltip();
            if (tooltip != null) {
                Tooltip.install(this, tooltip);
                oldTooltip = tooltip;
            }

            listener.registerChangeListener(tab.closableProperty(), "CLOSABLE");
            listener.registerChangeListener(tab.selectedProperty(), "SELECTED");
            listener.registerChangeListener(tab.textProperty(), "TEXT");
            listener.registerChangeListener(tab.graphicProperty(), "GRAPHIC");
            listener.registerChangeListener(tab.contextMenuProperty(), "CONTEXT_MENU");
            listener.registerChangeListener(tab.tooltipProperty(), "TOOLTIP");
            listener.registerChangeListener(tab.disableProperty(), "DISABLE");
            listener.registerChangeListener(tab.styleProperty(), "STYLE");
           
            tab.getStyleClass().addListener(weakStyleClassListener);

            listener.registerChangeListener(getSkinnable().tabClosingPolicyProperty(), "TAB_CLOSING_POLICY");
            listener.registerChangeListener(getSkinnable().sideProperty(), "SIDE");
            listener.registerChangeListener(getSkinnable().rotateGraphicProperty(), "ROTATE_GRAPHIC");
            listener.registerChangeListener(getSkinnable().tabMinWidthProperty(), "TAB_MIN_WIDTH");
            listener.registerChangeListener(getSkinnable().tabMaxWidthProperty(), "TAB_MAX_WIDTH");
            listener.registerChangeListener(getSkinnable().tabMinHeightProperty(), "TAB_MIN_HEIGHT");
            listener.registerChangeListener(getSkinnable().tabMaxHeightProperty(), "TAB_MAX_HEIGHT");
           
            getProperties().put(Tab.class, tab);
            getProperties().put(ContextMenu.class, tab.getContextMenu());

            setOnContextMenuRequested(new EventHandler<ContextMenuEvent>() {
                @Override public void handle(ContextMenuEvent me) {
                   if (getTab().getContextMenu() != null) {
                        getTab().getContextMenu().show(inner, me.getScreenX(), me.getScreenY());
                        me.consume();
                    }
                }
            });
            setOnMousePressed(new EventHandler<MouseEvent>() {
                @Override public void handle(MouseEvent me) {
                    if (getTab().isDisable()) {
                        return;
                    }
                    if (me.getButton().equals(MouseButton.MIDDLE)) {
                        if (showCloseButton()) {
                            Tab tab = getTab();
                            TabPaneBehavior behavior = getBehavior();
                            if (behavior.canCloseTab(tab)) {
                                removeListeners(tab);
                                behavior.closeTab(tab);   
                            }
                        }
                    } else if (me.getButton().equals(MouseButton.PRIMARY)) {
                        getBehavior().selectTab(getTab());
                    }
                }
            });   

            // initialize pseudo-class state
            pseudoClassStateChanged(SELECTED_PSEUDOCLASS_STATE, tab.isSelected());
            pseudoClassStateChanged(DISABLED_PSEUDOCLASS_STATE, tab.isDisable());
            final Side side = getSkinnable().getSide();
            pseudoClassStateChanged(TOP_PSEUDOCLASS_STATE, (side == Side.TOP));
            pseudoClassStateChanged(RIGHT_PSEUDOCLASS_STATE, (side == Side.RIGHT));
            pseudoClassStateChanged(BOTTOM_PSEUDOCLASS_STATE, (side == Side.BOTTOM));
            pseudoClassStateChanged(LEFT_PSEUDOCLASS_STATE, (side == Side.LEFT));
View Full Code Here


    public void applyHardwareMotorSettings(Tab _tab) throws Exception {
        /**
         * Apply Motor Settings to TinyG from GUI
         */
        Tab selectedTab = _tab.getTabPane().getSelectionModel().getSelectedItem();
        int _motorNumber = Integer.valueOf(selectedTab.getText().split(" ")[1].toString());
        Motor _motor = this.machine.getMotorByNumber(_motorNumber);

        GridPane _gp = (GridPane) _tab.getContent();
        int size = _gp.getChildren().size();
        int i;
View Full Code Here

    tab.setText(string);
  }

  @Override
  protected void createWidget() {
    this.tab = new Tab();
  }
View Full Code Here

    primaryStage.setScene(scene);
    primaryStage.show();
  }
 
  private Tab createHBoxLayout() {
    Tab tab = new Tab("HBoxLayout");
    tab.setClosable(false);
   
    HBox borderPane = new HBox();
    borderPane.setStyle("-fx-background-color: red;");
   
    Label l = new Label();
    l.setStyle("-fx-background-color: white;");
    l.setText("Hello World");
   
    borderPane.getChildren().add(l);
    tab.setContent(borderPane);
   
    return tab;
  }
View Full Code Here

    return tab;
  }
 
 
  private Tab createBorderLayout() {
    Tab tab = new Tab("BorderLayout");
    tab.setClosable(false);
   
    BorderPane borderPane = new BorderPane();
    borderPane.setStyle("-fx-background-color: red;");
   
    Label l = new Label();
    l.setStyle("-fx-background-color: white; -fx-padding: 10px;");
    l.setText("Hello World");
   
    borderPane.setCenter(l);
    tab.setContent(borderPane);
   
    return tab;
  }
View Full Code Here

   
    return tab;
  }
 
  private Tab createSashLayout() {
    Tab tab = new Tab("SashLayout");
    tab.setClosable(false);
   
    FillLayoutPane fillLayout = new FillLayoutPane();
    fillLayout.setStyle("-fx-background-color: red");
    fillLayout.setMarginHeight(5);
    fillLayout.setMarginWidth(5);
   
    SashLayoutPane sashLayout = new SashLayoutPane();
    sashLayout.setStyle("-fx-background-color: blue");
    sashLayout.getRoot().setHorizontal(true);
   
    Label l = new Label();
    l.setStyle("-fx-background-color: white");
   
    SashLayoutPane.MUIControl data = new SashLayoutPane.MUIControl();
    data.setWeight(49.81605562579014);
    sashLayout.getRoot().add(data);
    sashLayout.getChildren().add(l);
    sashLayout.setConstraint(l, data);
   
    l = new Label();
    l.setStyle("-fx-background-color: white");
    data = new SashLayoutPane.MUIControl();
    data.setWeight(50.377192982456144);
    sashLayout.getRoot().add(data);
    sashLayout.getChildren().add(l);
    sashLayout.setConstraint(l, data);
   
    fillLayout.getChildren().add(sashLayout);
   
    tab.setContent(fillLayout);
   
    return tab;
  }
View Full Code Here

   
    return tab;
  }
 
  private Tab createFillLayout() {
    Tab tab = new Tab("FillLayout");
    tab.setClosable(false);
   
    FillLayoutPane fillLayout = new FillLayoutPane();
    fillLayout.setStyle("-fx-background-color: red; -fx-blabla: true");
    fillLayout.setMarginHeight(5);
    fillLayout.setMarginWidth(5);
   
    Label l = new Label();
    l.setStyle("-fx-background-color: white");
    fillLayout.getChildren().add(l);
   
    l = new Label();
    l.setStyle("-fx-background-color: blue");
    fillLayout.getChildren().add(l);
   
    tab.setContent(fillLayout);
   
    return tab;
  }
View Full Code Here

    primaryStage.setTitle("Java Source Viewer");
    primaryStage.show();
  }

  private Tab createSourceViewer(File file) {
    Tab tab = new Tab(file.getName());
    tab.setContent(createSourceViewerPane(file));
    return tab;
  }
View Full Code Here

      tab.setUserData(this);
      return tab;
    }
   
    protected Tab createWidget() {
      final Tab t = FXTabFactory.createTab();
      ((FXTab)t).setCloseVetoHandler(new Callback<Tab, Boolean>() {
       
        @Override
        public Boolean call(Tab param) {
          if( closeCallback != null ) {
View Full Code Here

TOP

Related Classes of javafx.scene.control.Tab

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.