Javafx表视图不显示列中的数据

时间:2017-04-14 19:18:05

标签: java javafx tableview javafx-8

这是一个投诉管理系统的程序。我面临一个问题,即我无法填充tableview。当我点击刷新menuitem进行刷新(代码在下面你可以检查)时,它只显示一些数据的功能。 Before Clicking Refresh After Clicking Refresh

        package sample;

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

        /**
         * Created by Harshit on 12-04-2017.
         */
        public class vstaffmpage extends Application {
            @Override
            public void start(Stage primaryStage) throws Exception {
                Parent root = FXMLLoader.load(getClass().getResource("vstaff.fxml"));
                primaryStage.setTitle("Verification Staff");
                primaryStage.setScene(new Scene(root, 600, 400));
                primaryStage.setResizable(false);
                primaryStage.show();
            }
            public static void main(String[] args){ launch(args); }
            vstaffmpage(){
                Stage stage = new Stage();
                try {
                    start(stage);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

此文件用于将应用程序链接到FXML文件。

    package sample;

    import javafx.beans.property.SimpleStringProperty;

    public class Person {
       private final SimpleStringProperty complaint_no;
       private final SimpleStringProperty details;
    public Person() {
            this("", "");
        }

        public Person(String complaint_no, String details) {
            this.complaint_no = new SimpleStringProperty("complaint_no");
            this.details = new SimpleStringProperty("details");
        }

        public String getcomplaintno() {
            return complaint_no.get();
        }

        public void setcomplaintno(String complaintno) {
            complaint_no.set(complaintno);
        }

        public String getdetails() {
            return details.get();
        }

        public void setdetails(String detail) {
            details.set(detail);
        }

    }

此文件用于将数据放入字符串中,而不是将其放入observablelist中。我已经在oracle网站上创建了这个文件。

<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" style="-fx-background-color: #9f9de8;" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.vstaffcontroller">
   <children>
      <TableView fx:id="table" editable="true" layoutX="153.0" layoutY="64.0" prefHeight="316.0" prefWidth="433.0">
        <columns>
          <TableColumn fx:id="compcol1" prefWidth="127.0" resizable="false" text="Complaint Number" />
          <TableColumn fx:id="compcol2" minWidth="0.0" prefWidth="305.0" text="Details" />
        </columns>
      </TableView>
      <MenuBar fx:id="menubar" prefHeight="25.0" prefWidth="600.0">
        <menus>
          <Menu fx:id="File" mnemonicParsing="false" text="File">
            <items>
              <MenuItem fx:id="logoutmenu" mnemonicParsing="false" onAction="#logout" text="Logout" />
            </items>
          </Menu>
          <Menu fx:id="Edit" mnemonicParsing="false" text="Edit">
            <items>
              <MenuItem fx:id="refresh" mnemonicParsing="false" onAction="#refresh" text="Refresh" />
                  <MenuItem mnemonicParsing="false" text="Verify" />
                  <MenuItem mnemonicParsing="false" text="Bogus Complaint" />
            </items>
          </Menu>
          <Menu fx:id="Help" mnemonicParsing="false" text="Help">
            <items>
              <MenuItem fx:id="aboutmenu" mnemonicParsing="false" onAction="#about" text="About" />
            </items>
          </Menu>
        </menus>
      </MenuBar>
   </children>
</AnchorPane>

以下是该程序的FXML文件。     

<img src="" class="hover-btn">

0 个答案:

没有答案