簡體   English   中英

打開應用程序時,在Tabpane Javafx中更改選項視圖

[英]Change options view in tabpane javafx when opening the application

我創建了一個TabPane,其中有4個選項卡,每個選項卡中都有按鈕。 每次我運行我的應用程序時,在第一次運行時,它總是顯示出我已經按過'Maintain Questions'選項卡上的樣子,這當然不是真的, 就像這張圖片所示 我如何更改它,以使其在打開應用程序時不會顯示選項卡上的任何內容? 我是使用場景生成器完成的,因此這是我的fxml代碼:

<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane fx:id="anchorPane" focusTraversable="false" prefHeight="570.0" prefWidth="861.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.TeacherWindowController">
   <children>
      <ImageView fitHeight="669.0" fitWidth="985.0" focusTraversable="true" pickOnBounds="true">
         <image>
            <Image url="@../bigstock-Stack-Of-Books-70033240.jpg" />
         </image>
      </ImageView>
      <Text fx:id="welcomeText" fill="WHITE" layoutX="14.0" layoutY="40.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome" wrappingWidth="370.0">
         <font>
            <Font size="24.0" />
         </font></Text>
      <Text fx:id="TextGroup7" layoutX="365.0" layoutY="664.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Copyright © 2018 Group7" />
      <ImageView fx:id="Group7Logo" blendMode="MULTIPLY" fitHeight="150.0" fitWidth="200.0" layoutX="348.0" layoutY="572.0" pickOnBounds="true" preserveRatio="true">
         <image>
            <Image url="@../logo.jpg" />
         </image>
      </ImageView>
      <Text fx:id="date" fill="#fffdfd" layoutX="831.0" layoutY="39.0" strokeType="OUTSIDE" strokeWidth="0.0" wrappingWidth="140.0">
         <font>
            <Font size="24.0" />
         </font>
      </Text>
      <Button fx:id="addQuestiton" layoutX="298.0" layoutY="85.0" mnemonicParsing="false" prefHeight="31.0" prefWidth="173.0" text="Add Question" visible="false" />
      <Button fx:id="editOrRemoveQuestion" layoutX="298.0" layoutY="116.0" mnemonicParsing="false" prefHeight="31.0" prefWidth="173.0" text="Edit/Remove Question" visible="false" />
      <Button fx:id="logoutButton" layoutX="910.0" layoutY="52.0" mnemonicParsing="false" onAction="#logOutButtonHandler" text="Logout" />
      <TabPane fx:id="tabPane" focusTraversable="false" layoutX="13.0" layoutY="44.0" nodeOrientation="LEFT_TO_RIGHT" pickOnBounds="false" prefHeight="145.0" prefWidth="533.0" style="-fx-focus-traversable: false;" styleClass="TeacherWindow.css" stylesheets="@TeacherWindow.css" tabClosingPolicy="UNAVAILABLE">
        <tabs>
          <Tab closable="false" text="Maintain Questions">
            <content>
              <AnchorPane minHeight="0.0" minWidth="0.0" nodeOrientation="LEFT_TO_RIGHT" pickOnBounds="false" prefHeight="116.0" prefWidth="146.0" stylesheets="">
                     <children>
                        <Button focusTraversable="false" layoutX="-10.0" layoutY="31.0" mnemonicParsing="false" pickOnBounds="false" prefHeight="32.0" prefWidth="173.0" text="Edit/Remove Question" />
                        <Button focusTraversable="false" layoutX="-10.0" mnemonicParsing="false" pickOnBounds="false" prefHeight="31.0" prefWidth="173.0" text="Add Question" />
                     </children>
                  </AnchorPane>
            </content>
          </Tab>
          <Tab text="Maintain Exams">
            <content>
              <AnchorPane focusTraversable="false" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
            </content>
          </Tab>
            <Tab text="Order Reports">
              <content>
                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
              </content>
            </Tab>
            <Tab text="Confirm Grades">
              <content>
                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="106.0" prefWidth="763.0" />
              </content>
            </Tab>
        </tabs>
      </TabPane>
   </children>
</AnchorPane>

我認為如果沒有很多“棘手的解決方法”,這是不可能的。 雖然從圖片看來好像您將其用作Menu 那么,為什么不嘗試使用MenuBar而不是TabPane呢?

這是一個關於MenuBars的不錯的教程 ,可能會幫助您入門。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM