2 Replies Latest reply: Apr 2, 2013 10:29 AM by biochemistry43 RSS

    Open tab by clicking a button. Is it possible?

      Greetings and blessings to all.

      first overview ...

      - I have a file called Estructura_General.fxml
      - In this file I have included two files FXML (Barra_Estandar.fxml and Panel_Marcadores.FXML)
      - FXML files are included in the following manner:
      <HBox fx:id="herramientas"  prefWidth="1233.0">
              <fx:include source="Barra_estandard.fxml" />
               <fx:include fx:id="marcadoresPanel" source="Panel_Marcadores.fxml" />
      -Panel_Marcadores.fxml has a TabPane. The TabPane has three Tabs.

      I want to press a button that is contained in Barra_estandard.fxml, and to open the second tab (or I want)

      Panel_Marcadores.fxml not loaded Estructura_General.fxml fixedly, but opens when you press a button.

      Now I can make the panel opens when I press a button on Barra_Estandar.fxml, which I can not yet do is to open in a specific Tab.

      Is there a way?

      This image can help you understand what I want.

        • 1. Re: Open tab by clicking a button. Is it possible?
          Hi. It is possible. Here is an example using java:
          import javafx.application.Application;
          import javafx.event.ActionEvent;
          import javafx.event.EventHandler;
          import javafx.scene.Scene;
          import javafx.scene.control.Button;
          import javafx.scene.control.Tab;
          import javafx.scene.control.TabPane;
          import javafx.scene.layout.StackPane;
          import javafx.scene.layout.VBox;
          import javafx.scene.paint.Color;
          import javafx.scene.shape.Rectangle;
          import javafx.stage.Stage;
          public class SignaProj extends Application {
              public void start(Stage primaryStage) {
                  final TabPane tabPane = new TabPane();
                  Tab tab1 = new Tab();
                  tab1.setContent(new Rectangle(200, 200, Color.RED));
                   Tab tab2 = new Tab();
                  tab2.setContent(new Rectangle(200, 200, Color.BLUE));
                  final   Tab tab3 = new Tab();
                  tab3.setContent(new Rectangle(200, 200, Color.GREEN));
                  Button btn = new Button();
                  btn.setText("Push Green");
                  btn.setOnAction(new EventHandler<ActionEvent>() {
                      public void handle(ActionEvent event) {
                  VBox root = new VBox(10);
                  root.getChildren().addAll(tabPane, btn);
                  Scene scene = new Scene(root, 300, 250);
              public static void main(String[] args) {
          • 2. Re: Open tab by clicking a button. Is it possible?
            Well ... There you things to consider here.

            1. The FXML TabPane is created.
            2. The panel is an external FXML file (PanelMarcadores.fxml)
            3. The button is also on other external FXML. (BarraEstandard.fxml)
            4. Both (panelMarcadores.fxml and BarraEstandar.fxml) are included by fx: include in another file FXML different (EstructuraGeneral.fxml)

            What would then?

            Either way I'll be doing this so that attempts to tell me.