创建多个彼此独立的表JavaFX / Scenebuilder

时间:2017-04-27 18:29:57

标签: java javafx scenebuilder

我正在尝试构建3个不同的表,它们将彼此独立。由于某种原因,细胞显示但是空白。知道我做错了什么吗?

主:     包裹申请;

import java.util.logging.Level;
import java.util.logging.Logger;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;


public class Main extends Application {

    @Override
    public void start(Stage primaryStage) {
        try {
            BorderPane root = (BorderPane)FXMLLoader.load(getClass().getResource("GUISCENEBUILDER.fxml"));
            Scene scene = new Scene(root,850,700);
            scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
            primaryStage.setScene(scene);
            primaryStage.setTitle("Switch Utility");
            primaryStage.show();

        } catch(Exception e) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE,null,e);
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Application.launch(Main.class, (java.lang.String[]) null);
    }
}

产品类:(错误命名约定)(将其更改为Press1)

package application;

import javafx.beans.property.SimpleStringProperty;

public class Product {
    private final SimpleStringProperty windowTime;

    public Product(String windowTimes) {
        this.windowTime = new SimpleStringProperty(windowTimes);
    }

    public String getwindowTime() {
        return windowTime.get();
    }

    public void setwindowTime(String newTime) {
        windowTime.set(newTime);
    }

按2课:

    package application;

    import javafx.beans.property.SimpleStringProperty;

    public class Press2 {
        private final SimpleStringProperty windowTime2;


        public Press2(String windowTimes2) {
                this.windowTime2 = new SimpleStringProperty(windowTimes2);
            }

            public String getwindowTime2() {
                return windowTime2.get();
            }

            public void setwindowTime2(String newTime) {
                windowTime2.set(newTime);
            }

    }

Press3:

package application;

import javafx.beans.property.SimpleStringProperty;

public class Press3 {
    private final SimpleStringProperty windowTime3;


    public Press3(String windowTimes3) {
            this.windowTime3 = new SimpleStringProperty(windowTimes3);
        }

        public String getwindowTime2() {
            return windowTime3.get();
        }

        public void setwindowTime2(String newTime) {
            windowTime3.set(newTime);
        }

}

TableViewController:

package application;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;

public class TableViewController implements Initializable {
    //Defining table
    @FXML
    private TableView<Product> tableID;

    @FXML
    private TableView<Press2> tableID2;

    @FXML
    private TableView<Press3> tableID3;

    @FXML
    private TableColumn<Product, String> windowTime;

    @FXML
    private TableColumn<Press2, String> windowTime2;

    @FXML
    private TableColumn<Press3, String> windowTime3;


    /*
     * Creating all the table data
     */
    final ObservableList<Product> data = FXCollections.observableArrayList(
        new Product("7:00am - 8:30am"),
        new Product("10:00am - 11:10am"),
        new Product("12:00pm - 1:30pm"),
        new Product("3:00pm - 4:30pm")
    );
    final ObservableList<Press2> data2 = FXCollections.observableArrayList(
        new Press2("8:00am - 8:30am"),
        new Press2("10:00am - 11:10am"),
        new Press2("12:00pm - 1:30pm"),
        new Press2("3:00pm - 4:30pm")
    );
    final ObservableList<Press3> data3 = FXCollections.observableArrayList(
        new Press3("9:00am - 8:30am"),
        new Press3("10:00am - 11:10am"),
        new Press3("12:00pm - 1:30pm"),
        new Press3("3:00pm - 4:30pm")
    );

    /**
     * Initializes the controller class. This method is automatically called
     * after the fxml file has been loaded.
     */
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        windowTime.setCellValueFactory(new PropertyValueFactory<Product, String>("windowTime"));
        windowTime2.setCellValueFactory(new PropertyValueFactory<Press2, String>("windowTime2"));
        windowTime3.setCellValueFactory(new PropertyValueFactory<Press3, String>("windowTime3"));

        tableID.setItems(data);
        tableID2.setItems(data2);
        tableID3.setItems(data3);
    }

}

FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.DropShadow?>
<?import javafx.scene.effect.InnerShadow?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.paint.LinearGradient?>
<?import javafx.scene.paint.Stop?>
<?import javafx.scene.text.Font?>

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0" prefWidth="850.0" xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.TableViewController">
   <center>
      <TabPane prefHeight="472.0" prefWidth="850.0" tabClosingPolicy="UNAVAILABLE" BorderPane.alignment="CENTER">
        <tabs>
          <Tab text="Indigo">
            <content>
              <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="526.0" prefWidth="805.0">
                     <children>
                        <ImageView fitHeight="559.0" fitWidth="850.0" layoutY="-7.0">
                           <image>
                              <Image url="@../../bin/application/1.jpg" />
                           </image>
                        </ImageView>
                        <TableView fx:id="tableID" layoutX="651.0" layoutY="44.0" prefHeight="237.0" prefWidth="134.0">
                           <columns>
                              <TableColumn fx:id="windowTime" prefWidth="75.0" text="Window Times" />
                           </columns>
                           <columnResizePolicy>
                              <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
                           </columnResizePolicy>
                        </TableView>
                        <TextField layoutX="14.0" layoutY="55.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Output\Ready for Print" />
                        <Button layoutX="501.0" layoutY="55.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="87.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\CMYK+Spot" />
                        <Button layoutX="501.0" layoutY="87.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="21.0" text="Connection 1:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="166.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Output\Ready for Print" />
                        <Button layoutX="501.0" layoutY="166.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="198.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\CMYK+Spot" />
                        <Button layoutX="501.0" layoutY="198.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="132.0" text="Connection 2:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="276.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Output\Ready for Print" />
                        <Button layoutX="501.0" layoutY="276.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="308.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\CMYK+Spot" />
                        <Button layoutX="501.0" layoutY="308.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="242.0" text="Connection 3:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="387.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Output\Ready for Print" />
                        <Button layoutX="501.0" layoutY="387.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="419.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\CMYK+Spot" />
                        <Button layoutX="501.0" layoutY="419.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="353.0" text="Connection 4:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                     </children>
                  </AnchorPane>
            </content>
          </Tab>
          <Tab text="iGen">
            <content>
              <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                     <children>
                        <ImageView fitHeight="561.0" fitWidth="850.0" layoutY="-7.0">
                           <image>
                              <Image url="@../../bin/application/1.jpg" />
                           </image>
                        </ImageView>
                        <TableView fx:id="tableID2" layoutX="651.0" layoutY="44.0" prefHeight="237.0" prefWidth="134.0">
                           <columns>
                              <TableColumn fx:id="windowTime2" prefWidth="75.0" text="Window Times" />
                           </columns>
                           <columnResizePolicy>
                              <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
                           </columnResizePolicy>
                        </TableView>
                        <TextField layoutX="14.0" layoutY="55.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Envelopes\10x13 for Press" />
                        <Button layoutX="501.0" layoutY="55.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="87.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\10 x 13 Envelopes" />
                        <Button layoutX="501.0" layoutY="87.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="21.0" text="Connection 1:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="166.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Envelopes\10x13 for Press" />
                        <Button layoutX="501.0" layoutY="166.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="198.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\10 x 13 Envelopes" />
                        <Button layoutX="501.0" layoutY="198.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="132.0" text="Connection 2:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="276.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Envelopes\10x13 for Press" />
                        <Button layoutX="501.0" layoutY="276.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="308.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\10 x 13 Envelopes" />
                        <Button layoutX="501.0" layoutY="308.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="242.0" text="Connection 3:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="387.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Envelopes\10x13 for Press" />
                        <Button layoutX="501.0" layoutY="387.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="419.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\10 x 13 Envelopes" />
                        <Button layoutX="501.0" layoutY="419.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="353.0" text="Connection 4:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                     </children>
                  </AnchorPane>
            </content>
          </Tab>
             <Tab text="Memjet">
              <content>
                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                     <children>
                        <ImageView fitHeight="559.0" fitWidth="850.0" layoutY="-7.0">
                           <image>
                              <Image url="@../../bin/application/1.jpg" />
                           </image>
                        </ImageView>
                        <TableView fx:id="tableID3" layoutX="651.0" layoutY="44.0" prefHeight="237.0" prefWidth="134.0">
                          <columns>
                            <TableColumn fx:id="windowTime3" prefWidth="75.0" text="Window Times" />
                          </columns>
                           <columnResizePolicy>
                              <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
                           </columnResizePolicy>
                        </TableView>
                        <TextField layoutX="14.0" layoutY="55.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Envelopes\10x13 for Press" />
                        <Button layoutX="501.0" layoutY="55.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="87.0" prefHeight="25.0" prefWidth="475.0" promptText="A:\" />
                        <Button layoutX="501.0" layoutY="87.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="21.0" text="Connection 1:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="166.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Envelopes\10x13 for Press" />
                        <Button layoutX="501.0" layoutY="166.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="198.0" prefHeight="25.0" prefWidth="475.0" promptText="A:\" />
                        <Button layoutX="501.0" layoutY="198.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="132.0" text="Connection 2:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="276.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Envelopes\10x13 for Press" />
                        <Button layoutX="501.0" layoutY="276.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="308.0" prefHeight="25.0" prefWidth="475.0" promptText="J:\10 x 13 Envelopes" />
                        <Button layoutX="501.0" layoutY="308.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="242.0" text="Connection 3:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                        <TextField layoutX="14.0" layoutY="387.0" prefHeight="25.0" prefWidth="475.0" promptText="C:\Users\ASUprint\Desktop\Enfocus\Switch\ASU Print Online\Envelopes\10x13 for Press" />
                        <Button layoutX="501.0" layoutY="387.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <TextField layoutX="14.0" layoutY="419.0" prefHeight="25.0" prefWidth="475.0" promptText="A:\" />
                        <Button layoutX="501.0" layoutY="419.0" mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0" text="Browse" />
                        <Label layoutX="14.0" layoutY="353.0" text="Connection 4:" underline="true">
                           <font>
                              <Font name="Lucida Sans Demibold" size="20.0" />
                           </font>
                        </Label>
                     </children>
                  </AnchorPane>
              </content>
            </Tab>
        </tabs>
      </TabPane>
   </center>
   <top>
      <Pane prefHeight="126.0" prefWidth="850.0" BorderPane.alignment="CENTER">
         <children>
            <ImageView fitHeight="126.0" fitWidth="850.0">
               <image>
                  <Image url="@../../bin/application/1.1.jpg" />
               </image>
            </ImageView>
            <Button layoutX="489.0" layoutY="23.0" mnemonicParsing="false" style="-fx-background-color: #C9CED9;" text="Start">
               <font>
                  <Font size="38.0" />
               </font>
               <effect>
                  <InnerShadow blurType="ONE_PASS_BOX" color="WHITE" height="27.06" radius="6.265" width="0.0">
                     <input>
                        <DropShadow blurType="TWO_PASS_BOX" />
                     </input></InnerShadow>
               </effect>
               <cursor>
                  <Cursor fx:constant="HAND" />
               </cursor>
               <textFill>
                  <LinearGradient cycleMethod="REFLECT" endX="0.8523809523809524" startX="0.8333333333333334" startY="0.5523809523809524">
                     <stops>
                        <Stop color="#0a9e3b" />
                        <Stop color="#455445" offset="0.9961685823754789" />
                        <Stop color="#455445" offset="1.0" />
                     </stops>
                  </LinearGradient>
               </textFill>
            </Button>
            <Button depthTest="ENABLE" layoutX="639.0" layoutY="23.0" mnemonicParsing="false" style="-fx-background-color: #C9CED9;" text="Stop">
               <font>
                  <Font size="38.0" />
               </font>
               <effect>
                  <InnerShadow blurType="ONE_PASS_BOX" color="WHITE" height="27.06" radius="6.265" width="0.0">
                     <input>
                        <DropShadow blurType="TWO_PASS_BOX" />
                     </input></InnerShadow>
               </effect>
               <cursor>
                  <Cursor fx:constant="HAND" />
               </cursor>
               <textFill>
                  <LinearGradient cycleMethod="REFLECT" endX="0.8523809523809524" startX="0.8333333333333334" startY="0.5523809523809524">
                     <stops>
                        <Stop color="#c33838" />
                        <Stop color="#455445" offset="0.9961685823754789" />
                        <Stop color="#455445" offset="1.0" />
                     </stops>
                  </LinearGradient>
               </textFill>
            </Button>
            <ImageView fitHeight="118.0" fitWidth="300.0" layoutX="14.0" layoutY="5.0" pickOnBounds="true" preserveRatio="true">
               <image>
                  <Image url="@../../bin/application/ASU_PrintImagingLab_Horiz_RGB_MaroonGold_150ppi.png" />
               </image>
            </ImageView>
         </children>
         <cursor>
            <Cursor fx:constant="DEFAULT" />
         </cursor>
      </Pane>
   </top>
</BorderPane>

0 个答案:

没有答案