抱歉,标题含糊不清,但我认为我在 JavaFX BorderPane 类中发现了一个故障,但我并不肯定。所以我正在做的是在线程内的 javaFx 并发任务对象中运行此方法。这个方法一直有效,直到它到达打印语句。它打印出 1 然后不经过 root.setCenter 方法。如果我注释掉它继续运行的代码,否则它会卡在它上面,就像它处于无限循环中一样。需要注意的是,根(一个 boderpane 对象)本地存储在 JavaFX 主线程中。感谢您的任何建议。
// will be used to store all the sites we still need to visit so we can do
// a breadth first graph traversal of the hostsite
Queue<URL> unvistedURLs = new LinkedList<>();
LinkedList<Text> currentLevelText = new LinkedList<>();
Queue<URL> levelCheckpoints = new LinkedList<>();
int currentLevelHieght = 0;
// the origional host
String hostName = origin.getHost();
// temporary objects
HTMLLinks endHTMLLinks = null;
try
{
endHTMLLinks = new HTMLLinks(origin);
}
catch (IOException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
HostSiteInfo hostSiteInfo = new HostSiteInfo();
URL currentURL;
Group displayArea = new Group();
System.out.println(1);
root.setCenter(displayArea);
System.out.println(2);
// imediatley input the host as a site we need to visit
unvistedURLs.add(origin);
levelCheckpoints.offer(origin);
@Override
public void start(Stage primaryStage)
{
try
{
final BorderPane root = new BorderPane();
Scene scene = new Scene(root, 1600, 1000);
@SuppressWarnings("rawtypes")
Thread renderThread = new Thread(new Task(){
@Override
protected Object call() throws Exception
{
try
{
WebSpider.traverseURLs(root,
new URL("http://www.georgefox.edu/"),
new PrintStream(System.out));
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}});
renderThread.setDaemon(true);
renderThread.start();
JavaFx 应用程序的根在 this start 方法中初始化。