Javafx 2 JAVAFX Tableview在使用JAVA结果调整应用程序大小时挂起

Javafx 2 JAVAFX Tableview在使用JAVA结果调整应用程序大小时挂起,javafx-2,tableview,freeze,Javafx 2,Tableview,Freeze,我有一个简单的javafx应用程序,在调整大小时挂起 应用程序是使用jdk1.7.0_10编译/构建的 操作系统:Windows 8 IDE:NetBeans 7.2.1 当我填充底部表格并通过移动应用程序的右边框开始调整大小时,就会出现问题。有时我需要调整一下大小,移动拆分窗格的内部边框和外部应用程序边框,直到它崩溃。当该行为空时,即表中没有填充任何内容,然后一切正常-没有挂起,我可以根据需要在各个方向调整大小-并且没有挂起任何内容。 应用程序挂起并在Netbeans输出窗口中以Java结果2

我有一个简单的javafx应用程序,在调整大小时挂起

应用程序是使用jdk1.7.0_10编译/构建的
操作系统:Windows 8
IDE:NetBeans 7.2.1

当我填充底部表格并通过移动应用程序的右边框开始调整大小时,就会出现问题。有时我需要调整一下大小,移动拆分窗格的内部边框和外部应用程序边框,直到它崩溃。当该行为空时,即表中没有填充任何内容,然后一切正常-没有挂起,我可以根据需要在各个方向调整大小-并且没有挂起任何内容。 应用程序挂起并在Netbeans输出窗口中以Java结果255结束。
可能是什么?没有日志、异常,什么都没有……它让我发疯,在上面浪费了这么多时间:(

这是我的控制器:

public class MyFXMLController implements Initializable {

@FXML
TableView<Person> table;

@FXML
TableColumn<Person, String> firstNameCol;
@FXML
TableColumn<Person, String> lastNameCol;
@FXML
TableColumn<Person, String> carCol;

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO

    firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
    lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
    carCol.setCellValueFactory(new PropertyValueFactory("car"));

    Person p1 = new Person();
    p1.setFirstName("A");
    p1.setLastName("B");
    p1.setCar("ferrari");
    ObservableList<Person> teamMembers = FXCollections.observableArrayList(p1);
    table.setItems(teamMembers);
}
}

不过,我看不到这里有任何具体的问题。但这可能是内存管理的问题。请尝试将数据类作为控制器类中的子类设置为静态

public class TestTableView extends Application {

@Override
public void start(Stage primaryStage) {
    Button btn = new Button();
    btn.setText("Say 'Hello World'");
    btn.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            System.out.println("Hello World!");
        }
    });

    AnchorPane page = null;
    try {
        page = (AnchorPane) FXMLLoader.load(TestTableView.class.getResource("/testtableview/myFXML.fxml"));
    } catch (IOException ex) {
        Logger.getLogger(TestTableView.class.getName()).log(Level.SEVERE, null, ex);
    }
    Scene scene = new Scene(page);
    primaryStage.setScene(scene);
    primaryStage.setTitle("my");
    primaryStage.show();
}

/**
 * The main() method is ignored in correctly deployed JavaFX application.
 * main() serves only as fallback in case the application can not be
 * launched through deployment artifacts, e.g., in IDEs with limited FX
 * support. NetBeans ignores main().
 *
 * @param args the command line arguments
 */
public static void main(String[] args) {
    launch(args);

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

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

    <AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="715.0000999999975" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml" fx:controller="testtableview.MyFXMLController">
      <children>
        <SplitPane dividerPositions="0.22720894429047145" focusTraversable="true" prefHeight="400.0" prefWidth="600.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
          <items>
            <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
              <children>
                <TreeView prefHeight="398.0" prefWidth="159.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
              </children>
            </AnchorPane>
            <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">
              <children>
                <SplitPane dividerPositions="0.5" focusTraversable="true" orientation="VERTICAL" prefHeight="398.0" prefWidth="491.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                  <items>
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
                      <children>
                        <TableView id="table" prefHeight="195.0" prefWidth="489.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                          <columns>
                            <TableColumn prefWidth="75.0" text="Column X" />
                            <TableColumn prefWidth="75.0" text="Column X">
                              <columns>
                                <TableColumn prefWidth="75.0" text="Column X" />
                                <TableColumn prefWidth="75.0" text="Column X" />
                              </columns>
                            </TableColumn>
                            <TableColumn prefWidth="75.0" text="Column X">
                              <columns>
                                <TableColumn prefWidth="75.0" text="Column X" />
                                <TableColumn prefWidth="75.0" text="Column X" />
                              </columns>
                            </TableColumn>
                            <TableColumn prefWidth="75.0" text="Column X" />
                            <TableColumn prefWidth="75.0" text="Column X" />
                          </columns>
                        </TableView>
                      </children>
                    </AnchorPane>
                    <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0">
                      <children>
                        <TableView fx:id="table" prefHeight="195.0" prefWidth="489.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                          <columns>
                            <TableColumn prefWidth="75.0" text="firstNameCol" fx:id="firstNameCol" />
                            <TableColumn prefWidth="75.0" text="lastNameCol" fx:id="lastNameCol" />
                            <TableColumn prefWidth="75.0" text="carCol" fx:id="carCol" />
                            <TableColumn prefWidth="75.0" text="Column X" />
                            <TableColumn prefWidth="75.0" text="Column X" />
                            <TableColumn prefWidth="75.0" text="Column X" />
                          </columns>
                        </TableView>
                      </children>
                    </AnchorPane>
                  </items>
                </SplitPane>
              </children>
            </AnchorPane>
          </items>
        </SplitPane>
      </children>
      <stylesheets>
        <URL value="@myfxml.css" />
      </stylesheets>
    </AnchorPane>
package testtableview;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

public class Person {

    private StringProperty firstName;

    public void setFirstName(String value) {
        firstNameProperty().set(value);
    }

    public String getFirstName() {
        return firstNameProperty().get();
    }

    public StringProperty firstNameProperty() {
        if (firstName == null) {
            firstName = new SimpleStringProperty(this, "firstName");
        }
        return firstName;
    }
    private StringProperty lastName;

    public void setLastName(String value) {
        lastNameProperty().set(value);
    }

    public String getLastName() {
        return lastNameProperty().get();
    }

    public StringProperty lastNameProperty() {
        if (lastName == null) {
            lastName = new SimpleStringProperty(this, "lastName");
        }
        return lastName;
    }

       private StringProperty car;

    public void setCar(String value) {
        carProperty().set(value);
    }

    public String getCar() {
        return carProperty().get();
    }

    public StringProperty carProperty() {
        if (car == null) {
            car = new SimpleStringProperty(this, "car");
        }
        return car;
    }

}