【发布时间】:2018-01-12 17:24:22
【问题描述】:
我有一个简单的 javaFx 应用程序,它从 html 结构中搜索一些文本和一些元素。它有一个小窗户,一个舞台。程序可以正常运行,但是当程序运行时,舞台(javaFx 窗口)没有响应,它冻结了。 我想我应该在一个新线程中运行我的舞台,但它没有用。这是我的程序提到的部分。 如何在不冻结窗口的情况下运行我的程序?
public class Real_estate extends Application implements Runnable {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
stage.getIcons().add(new Image("http://icons.iconarchive.com/icons/paomedia/small-n-flat/1024/house-icon.png"));
stage.setTitle("Simple program 0.8");
stage.setWidth(300);
stage.setHeight(300);
stage.setResizable(false);
HtmlSearch htmlSearch = new HtmlSearch ();
htmlSearch .toDatabase("http://example.com");
}
public static void main(String[] args) {
launch(args);
}
@Override
public void run() {
throw new UnsupportedOperationException("Not supported yet.");
}
【问题讨论】: