NPE is JavaFX Task
Peter Penzov
peter.penzov at gmail.com
Wed May 27 11:25:50 UTC 2015
Update: Same result with this code:
public void addNewTab(DynamicTreeNodeModel nodeModel)
{
final Tab tab = new Tab();
final ProgressBar progressBar = new ProgressBar();
final Task<BorderPane> loadDataTask = new Task<BorderPane>()
{
@Override
public BorderPane call() throws Exception
{
Content content = new Content(primaryStage,
treeView.getSelectionModel().getSelectedItem());
return content.initContentData();
}
};
tab.setContent(progressBar);
loadDataTask.setOnSucceeded(new EventHandler<WorkerStateEvent>()
{
@Override
public void handle(WorkerStateEvent event)
{
BorderPane data = loadDataTask.getValue();
tab.setContent(data);
}
});
final Thread thread = new Thread(loadDataTask);
thread.setDaemon(true);
thread.start();
newTabLabel = new Label(nodeModel.getName());
tab.setStyle("-fx-focus-color: transparent;"); // Remove the blue
dashed label from label
tab.setGraphic(newTabLabel);
tab.setContextMenu(makeTabContextMenu(tab, newTabLabel, tabPane));
tabPane.getTabs().add(0, tab);
tabPane.getSelectionModel().select(tab);
tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.ALL_TABS);
}
On Wed, May 27, 2015 at 12:56 PM, Peter Penzov <peter.penzov at gmail.com>
wrote:
> Hi All,
> I have a question about a issue that I have with JavaFX Task. I'm
> using the code from this example to display progress bar in TabPane when I
> click on TreeView Node:
>
> http://stackoverflow.com/questions/22803845/loading-logic-for-javafx-task
>
> For some reason when I click multiple times on the node I get this
> exception:
>
>
> Exception in thread "JavaFX Application Thread"
> java.lang.NullPointerException
> at com.sun.javafx.css.StyleManager.findMatchingStyles(Unknown
> Source)
> at javafx.scene.CssStyleHelper.createStyleHelper(Unknown Source)
> at javafx.scene.Node.reapplyCss(Unknown Source)
> at javafx.scene.Node.impl_reapplyCSS(Unknown Source)
> at javafx.scene.Node.invalidatedScenes(Unknown Source)
> at javafx.scene.Node.setScenes(Unknown Source)
> at javafx.scene.Parent$1.onChanged(Unknown Source)
> at
> com.sun.javafx.collections.TrackableObservableList.lambda$new$19(Unknown
> Source)
> at
> com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(Unknown
> Sourc
> e)
> at
> com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(Unknown
> Source)
> at javafx.collections.ObservableListBase.fireChange(Unknown Source)
> at javafx.collections.ListChangeBuilder.commit(Unknown Source)
> at javafx.collections.ListChangeBuilder.endChange(Unknown Source)
> at javafx.collections.ObservableListBase.endChange(Unknown Source)
> at javafx.collections.ModifiableObservableListBase.add(Unknown
> Source)
> at java.util.AbstractList.add(Unknown Source)
> at com.sun.javafx.collections.VetoableListDecorator.add(Unknown
> Source)
> at
> com.sun.javafx.scene.control.skin.ProgressIndicatorSkin$IndeterminateSpinner.rebuild(Unkn
> own Source)
> at
> com.sun.javafx.scene.control.skin.ProgressIndicatorSkin$IndeterminateSpinner.access$400(U
> nknown Source)
> at
> com.sun.javafx.scene.control.skin.ProgressIndicatorSkin$2.invalidated(Unknown
> Source)
> at javafx.beans.property.IntegerPropertyBase.markInvalid(Unknown
> Source)
> at javafx.beans.property.IntegerPropertyBase.set(Unknown Source)
> at javafx.css.StyleableIntegerProperty.set(Unknown Source)
> at javafx.beans.property.IntegerProperty.setValue(Unknown Source)
> at javafx.css.StyleableIntegerProperty.applyStyle(Unknown Source)
> at javafx.css.StyleableIntegerProperty.applyStyle(Unknown Source)
> at javafx.scene.CssStyleHelper.transitionToState(Unknown Source)
> at javafx.scene.Node.impl_processCSS(Unknown Source)
> at javafx.scene.Parent.impl_processCSS(Unknown Source)
> at javafx.scene.control.Control.impl_processCSS(Unknown Source)
> at javafx.scene.Parent.impl_processCSS(Unknown Source)
> at javafx.scene.Parent.impl_processCSS(Unknown Source)
> at javafx.scene.Node.processCSS(Unknown Source)
> at javafx.scene.Node.processCSS(Unknown Source)
> at javafx.scene.Node.processCSS(Unknown Source)
> at javafx.scene.Node.processCSS(Unknown Source)
> at javafx.scene.Node.processCSS(Unknown Source)
> at javafx.scene.Node.processCSS(Unknown Source)
> at javafx.scene.Scene.doCSSPass(Unknown Source)
> at javafx.scene.Scene.access$3600(Unknown Source)
> at javafx.scene.Scene$ScenePulseListener.pulse(Unknown Source)
> at com.sun.javafx.tk.Toolkit.lambda$runPulse$31(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
> at com.sun.javafx.tk.Toolkit.runPulse(Unknown Source)
> at com.sun.javafx.tk.Toolkit.firePulse(Unknown Source)
> at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
> at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(Unknown Source)
> at
> com.sun.javafx.tk.quantum.QuantumToolkit.lambda$runToolkit$401(Unknown
> Source)
> at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown
> Source)
> at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
> at com.sun.glass.ui.win.WinApplication.lambda$null$146(Unknown
> Source)
> at java.lang.Thread.run(Unknown Source)
>
>
> Can you advice me is this JavaFX issue or the code that I'm using is
> incorrect?
>
> BR,
> Peter
>
> ref
> http://stackoverflow.com/questions/22803845/loading-logic-for-javafx-task
>
More information about the openjfx-dev
mailing list