Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaFX TableView using FX Objects
    primarykey
    data
    text
    <p>I am trying to put a stack panel in my <code>TableView</code> and I keep getting errors.</p> <p>I suspect it is my lack of understanding of creating the Cell Value Factory.</p> <p>My Code looks like:</p> <pre><code>TableColumn obj = new TableColumn("Func " + i); final int index = i; obj.setCellValueFactory(new Callback&lt;TableColumn.CellDataFeatures&lt;ObservableList&lt;String&gt;, String&gt;, TableCell&lt;ObservableList&lt;String&gt;, String&gt;&gt;() { @Override public TableCell&lt;ObservableList&lt;String&gt;, String&gt; call(final CellDataFeatures&lt;ObservableList&lt;String&gt;, String&gt; cdf) { if (index + 2 &gt;= cdf.getValue().size()) { return null; } //return new SimpleStringProperty(cdf.getValue().get(index + 2)); return new TableCell&lt;ObservableList&lt;String&gt;, String&gt;(){ Label funcLbl = new Label(cdf.getValue().get(index+2)); StackPane sp = new StackPane(); @Override protected void updateItem(String item, boolean empty) { super.updateItem(item, empty); //To change body of generated methods, choose Tools | Templates. sp.getChildren().add(funcLbl); setGraphic(sp); } }; } }); obj.setMinWidth(100); this.getColumns().add(obj); </code></pre> <p>And the Error I am getting is</p> <pre><code>SEVERE: javafx.scene.control.Control loadSkinClass Failed to load skin 'StringProperty [bean: PinTable[id=null, styleClass=table-view], name: skinClassName, value: com.sun.javafx.scene.control.skin.TableViewSkin]' for control PinTable[id=null, styleClass=table-view] java.lang.ClassCastException: mapr.components.mainui.render.table.MyTable$3$1 cannot be cast to javafx.beans.value.ObservableValue at javafx.scene.control.TableColumn.getCellObservableValue(TableColumn.java:1209) at javafx.scene.control.TableColumn.getCellObservableValue(TableColumn.java:1179) at javafx.scene.control.TableCell.updateItem(TableCell.java:543) at javafx.scene.control.TableCell.indexChanged(TableCell.java:105) at javafx.scene.control.TableCell$1.invalidated(TableCell.java:93) at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:155) at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100) at javafx.beans.property.ReadOnlyIntegerWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:195) at javafx.beans.property.ReadOnlyIntegerWrapper.fireValueChangedEvent(ReadOnlyIntegerWrapper.java:161) at javafx.beans.property.IntegerPropertyBase.markInvalid(IntegerPropertyBase.java:130) at javafx.beans.property.IntegerPropertyBase.set(IntegerPropertyBase.java:163) at javafx.scene.control.IndexedCell.updateIndex(IndexedCell.java:112) at com.sun.javafx.scene.control.skin.TableColumnHeader.resizeToFit(TableColumnHeader.java:619) at com.sun.javafx.scene.control.skin.TableColumnHeader$1.invalidated(TableColumnHeader.java:138) at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:155) at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:100) at javafx.beans.property.ReadOnlyObjectWrapper$ReadOnlyPropertyImpl.fireValueChangedEvent(ReadOnlyObjectWrapper.java:195) at javafx.beans.property.ReadOnlyObjectWrapper.fireValueChangedEvent(ReadOnlyObjectWrapper.java:161) at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:130) at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163) at javafx.scene.Node.setScene(Node.java:661) at javafx.scene.Parent.computeDirtyScene(Parent.java:599) at javafx.scene.Parent.sceneChanged(Parent.java:612) at javafx.scene.Node$4.invalidated(Node.java:699) at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:129) at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163) at javafx.scene.Node.setScene(Node.java:661) at javafx.scene.Parent.computeDirtyScene(Parent.java:599) at javafx.scene.Parent.sceneChanged(Parent.java:612) at javafx.scene.Node$4.invalidated(Node.java:699) at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:129) at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163) at javafx.scene.Node.setScene(Node.java:661) at javafx.scene.Parent.computeDirtyScene(Parent.java:599) at javafx.scene.Parent.sceneChanged(Parent.java:612) at javafx.scene.Node$4.invalidated(Node.java:699) at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:129) at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163) at javafx.scene.Node.setScene(Node.java:661) at javafx.scene.Parent$1.onChanged(Parent.java:425) at com.sun.javafx.collections.VetoableObservableList.callObservers(VetoableObservableList.java:83) at com.sun.javafx.collections.ObservableListWrapper.setAll(ObservableListWrapper.java:303) at com.sun.javafx.collections.VetoableObservableList.setAll(VetoableObservableList.java:92) at com.sun.javafx.collections.ObservableListWrapper.setAll(ObservableListWrapper.java:314) at javafx.scene.control.Control.updateChildren(Control.java:947) at javafx.scene.control.Control.access$100(Control.java:70) at javafx.scene.control.Control$1.invalidated(Control.java:207) at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:129) at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163) at com.sun.javafx.css.StyleableObjectProperty.set(StyleableObjectProperty.java:70) at javafx.scene.control.Control$1.set(Control.java:186) at javafx.scene.control.Control$1.set(Control.java:171) at javafx.scene.control.Control.loadSkinClass(Control.java:1047) at javafx.scene.control.Control.access$500(Control.java:70) at javafx.scene.control.Control$12.invalidated(Control.java:972) at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:127) at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:161) at com.sun.javafx.css.StyleableStringProperty.set(StyleableStringProperty.java:71) at javafx.scene.control.Control$12.set(Control.java:964) at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:59) at com.sun.javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:31) at com.sun.javafx.css.StyleableProperty.set(StyleableProperty.java:70) at com.sun.javafx.css.StyleHelper.transitionToState(StyleHelper.java:902) at javafx.scene.Node.impl_processCSS(Node.java:7415) at javafx.scene.Parent.impl_processCSS(Parent.java:1146) at javafx.scene.control.Control.impl_processCSS(Control.java:1154) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.control.Control.impl_processCSS(Control.java:1154) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.control.Control.impl_processCSS(Control.java:1154) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Parent.impl_processCSS(Parent.java:1153) at javafx.scene.Node.processCSS(Node.java:7383) at javafx.scene.Node.processCSS(Node.java:7377) at javafx.scene.Node.processCSS(Node.java:7377) at javafx.scene.Scene.doCSSPass(Scene.java:446) at javafx.scene.Scene.access$3800(Scene.java:170) at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2202) at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:363) at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:460) at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:329) at com.sun.glass.ui.win.WinApplication._runLoop(Native Method) at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29) at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73) at java.lang.Thread.run(Thread.java:724) </code></pre> <p>I am trying to convert from using a </p> <pre><code>public ObservableValue&lt;String&gt; call(CellDataFeatures&lt;ObservableList&lt;String&gt;, String&gt; cdf) </code></pre> <p>and only returning a <code>SimpleStringProperty</code> to returning a <code>TableCell&lt;ObservableList&lt;String&gt;</code>, String> that has a <code>StackPane</code> as its content with the <code>String</code> held in a <code>Label</code> (I want to create actions based on clicking on the stack pane).</p> <p>Any help on understanding the transition would be great!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload