【发布时间】:2016-06-20 05:39:14
【问题描述】:
对不起,标题含糊不清,但我认为我在 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 方法中初始化。
【问题讨论】:
-
root在哪里初始化? -
抱歉,由于某种原因,本网站认为有些不是代码。
-
我想这可能是我从匿名类中的匿名类中引用它。但如果这是问题所在,我认为它会崩溃。
-
我修复了您的代码格式,并根据不同的缩进和不同的上下文(完整方法与 sn-p-y 代码)将其拆分为两个块。如果它本来就是一个块,请随时将其合并回一个块中。
-
谢谢它是两个
标签: java java-8 javafx-8 borderpane