Skip to main content

JavaFX run tim exception when splitview is bind with (Widget)

1 reply [Last post]
kashinj
Offline
Joined: 2008-01-08

Hi,

I'm creating a view like this:

getRightView() : Widget
{
based on some logic, I'll be returning varied widgets.

}

Frame{
....
......

center: GridPanel {
// border: EtchedBorder
rows: 1
columns: 1
vgap: 5
hgap: 5
cells: SplitPane{
orientation: HORIZONTAL
content: [
SplitView{
weight: 0.9
content: bind lazy (Widget) this.getRightView()
} // End SplitView
]
} // End of Split Pane
}//End of Centre GridPanel
}//End Frame

So, I want to lazy bind (content with getRightView()), but it is throwing a run time exception as follows:

uncaught FX exception: java.lang.NullPointerException java.lang.NullPointerException

at split.add(p.id, p.content.getComponent()) ("jar:file:/C:/Documents%20and%20Settings/knukala/.netbeans/6.0/modules/ext/javafx/javafxrt.jar!/javafx/ui/SplitPane.fx", Line 60)
at split.add(p.id, p.content.getComponent()) ("jar:file:/C:/Documents%20and%20Settings/knukala/.netbeans/6.0/modules/ext/javafx/javafxrt.jar!/javafx/ui/SplitPane.fx", Line 60)
at jpanel.add(i.getComponent()) ("jar:file:/C:/Documents%20and%20Settings/knukala/.netbeans/6.0/modules/ext/javafx/javafxrt.jar!/javafx/ui/GridPanel.fx", Line 54)
at jpanel.add(center.getComponent(), <>.CENTER) ("jar:file:/C:/Documents%20and%20Settings/knukala/.netbeans/6.0/modules/ext/javafx/javafxrt.jar!/javafx/ui/BorderPanel.fx", Line 34)
at frame.setContentPane(w.getComponent()) ("jar:file:/C:/Documents%20and%20Settings/knukala/.netbeans/6.0/modules/ext/javafx/javafxrt.jar!/javafx/ui/Frame.fx", Line 303)
at this.setContentPane(value) ("jar:file:/C:/Documents%20and%20Settings/knukala/.netbeans/6.0/modules/ext/javafx/javafxrt.jar!/javafx/ui/Frame.fx", Line 298)
at this.m_frame = new Frame {width: 1000, height: 550, title: "VI-Client Extension", content: new BorderPanel {border: new EmptyBorder {left: 1, right: 1}, top: new GridPanel {rows: 2, columns: 1, vgap: 10, hgap: 10, cells: [new GridPanel {rows: 1, columns: 1, vgap: 10, hgap: 10, cells: bind getMenuBar()}, new GridPanel {rows: 1, columns: 1, vgap: 10, hgap: 10, cells: bind getToolBar()}]}, center: new GridPanel {rows: 1, columns: 1, vgap: 5, hgap: 5, cells: new SplitPane {orientation: HORIZONTAL, content: [new SplitView {weight: 0.9, content: bind lazy (Widget)this.getRightView()}]}}}, visible: true} ("file:/Z:/src/build/classes/elxsanmgr/ui/jfx/ESMUI.fx", Line 144)
at ui.render() ("file:/Z:/src/VMWare/VI%20Extension/build/classes/elxsanmgr/ui/jfx/Main.fx", Line 40)
Caused by: java.lang.NullPointerException
at java.awt.Container.addImpl(Container.java:1019)
at java.awt.Container.add(Container.java:364)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.invokeMethod(TypeFactoryImpl.java:11238)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20487)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25507)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doFor(TypeFactoryImpl.java:25454)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25620)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:24748)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20675)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:19611)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.declareVariables(TypeFactoryImpl.java:11593)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25500)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25559)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:24748)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20675)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20399)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25507)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doFor(TypeFactoryImpl.java:25454)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25620)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:24748)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20675)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:19611)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.declareVariables(TypeFactoryImpl.java:11593)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25500)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25559)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:24748)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20675)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20399)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25507)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25559)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:24748)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20675)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:19611)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.declareVariables(TypeFactoryImpl.java:11593)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25500)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25559)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:24748)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20675)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20399)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25507)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25559)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:24748)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20675)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25507)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.callChangeRule(TypeFactoryImpl.java:24588)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl.callChangeRule(TypeFactoryImpl.java:26024)
at net.java.javafx.typeImpl.ExpressionFactoryImpl.callChangeRule(ExpressionFactoryImpl.java:9469)
at net.java.javafx.typeImpl.ExpressionFactoryImpl$Trigger.callChangeRule0(ExpressionFactoryImpl.java:270)
at net.java.javafx.typeImpl.ExpressionFactoryImpl$Trigger.attributeValueReplaced(ExpressionFactoryImpl.java:289)
at net.java.javafx.typeImpl.ExpressionFactoryImpl$VTable.fireReplaceTrigger(ExpressionFactoryImpl.java:412)
at net.java.javafx.typeImpl.ExpressionFactoryImpl.fireReplaceTrigger(ExpressionFactoryImpl.java:9536)
at net.java.javafx.typeImpl.PL$2.attributeValueReplaced(PL.java:251)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl.fireAttributeValueReplaced(TypeFactoryImpl.java:4384)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ValueImpl.setAttribute(TypeFactoryImpl.java:8361)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ValueImpl.addAttribute(TypeFactoryImpl.java:8540)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:22568)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.assignment(TypeFactoryImpl.java:24207)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:19829)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25507)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:24748)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20675)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$ExpressionValueImpl.execute(TypeFactoryImpl.java:20743)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25507)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.doStmtList(TypeFactoryImpl.java:25469)
at net.java.javafx.typeImpl.TypeFactoryImpl$ModuleImpl$Interpreter.interpret(TypeFactoryImpl.java:25622)
at net.java.javafx.typeImpl.Compilation$CompilationUnitImpl.init(Compilation.java:521)
at net.java.javafx.typeImpl.Compilation$CompilationUnitImpl.init(Compilation.java:456)
at net.java.javafx.typeImpl.Compilation.doCompile(Compilation.java:1080)
at net.java.javafx.typeImpl.Compilation.compile(Compilation.java:837)
at net.java.javafx.typeImpl.Compilation.compile(Compilation.java:819)
at net.java.javafx.typeImpl.F3Shell$1.run(F3Shell.java:93)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Z:\src\\nbproject\build-impl.xml:414: The following error occurred while executing this line:
Z:\src\\nbproject\build-impl.xml:261: Java returned: 1
BUILD FAILED (total time: 8 seconds)

Initially I tried with some Label{} widget which accepts, so I wrote a function which will return a (Widget) which i'm not aware at this point but I want to cast it to widget.

I'm interested to know, is there any possibility of bind it like this?

Regards,
kvn.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jim_weaver
Offline
Joined: 2007-05-18

The Freebase Browser application (see blog post http://learnjavafx.typepad.com/weblog/2007/10/spotting-javafx.html) uses a SplitPane. To change the Widget shown in the right pane, I used a CardPanel. Each "card" in the CardPanel contains a different Widget subclass, and I just switch between them. This works well if there is a finite set of widgets to show in that pane.

By the way, any subclass of Widget can be assigned to a reference that expects a Widget. No casting necessary.

Thanks,
Jim Weaver
"Helping You Become a JavaFXpert" weblog: http://javafxpert.com