• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Himai Minh

setting tableview cell contents to non-standard items

Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm trying to write a javafx based app that is gonig to display a list of music tracks in a tableview that will show the album cover art in the first column, artist name and track title in the middle column and then a play button in the third column. All the relevant file info is contained in an xml file that is read at runtime. So far, the code displays the table, reads the xml file and parses the data correctly and displayed the xml file path strings in the table entries. Now I am actually trying to have ti display the cover art image in the first column instead of the file path. I have spent a couple of days looking at various implementations of this general idea all over the web, but when I try and implement them, I crash and burn. First off, here is code (it is in a javafx controller since music is handled as its own screen and controller class):

When the updateItem method for artWorkTableCell is called, the artWork parameter passed in is null, so we die on a null pointer exception. I've stepped through to where the library track is created, and the album art file path is stored fine as part of the music track data. I'm sure I must somehow be messing up the overloading.

Here is the runtime error I get (showing only for the first table row entry):

SEVERE: javafx.scene.control.Control loadSkinClass Failed to load skin 'StringProperty [bean: TableRow[id=null, styleClass=cell indexed-cell table-row-cell], name: skinClassName, value: com.sun.javafx.scene.control.skin.TableRowSkin]' for control TableRow[id=null, styleClass=cell indexed-cell table-row-cell]
at com.craig.test.sample.music.MusicController$ArtWorkTableCell.updateItem(MusicController.java:145)
at com.craig.test.sample.music.MusicController$ArtWorkTableCell.updateItem(MusicController.java:1)
at javafx.scene.control.TableCell.updateItem(TableCell.java:549)
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.TableRowSkin.updateCells(TableRowSkin.java:251)
at com.sun.javafx.scene.control.skin.TableRowSkin.<init>(TableRowSkin.java:88)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at javafx.scene.control.Control.loadSkinClass(Control.java:1044)
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:900)
at javafx.scene.Node.impl_processCSS(Node.java:7419)
at javafx.scene.Parent.impl_processCSS(Parent.java:1146)
at javafx.scene.control.Control.impl_processCSS(Control.java:1154)
at com.sun.javafx.scene.control.skin.VirtualFlow.setCellIndex(VirtualFlow.java:1598)
at com.sun.javafx.scene.control.skin.VirtualFlow.getCell(VirtualFlow.java:1500)
at com.sun.javafx.scene.control.skin.VirtualFlow.getCellLength(VirtualFlow.java:1523)
at com.sun.javafx.scene.control.skin.VirtualFlow$3.call(VirtualFlow.java:478)
at com.sun.javafx.scene.control.skin.VirtualFlow$3.call(VirtualFlow.java:476)
at com.sun.javafx.scene.control.skin.PositionMapper.computeViewportOffset(PositionMapper.java:143)
at com.sun.javafx.scene.control.skin.VirtualFlow.layoutChildren(VirtualFlow.java:1001)
at javafx.scene.Parent.layout(Parent.java:1018)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Parent.layout(Parent.java:1028)
at javafx.scene.Scene.layoutDirtyRoots(Scene.java:516)
at javafx.scene.Scene.doLayoutPass(Scene.java:487)
at javafx.scene.Scene.access$3900(Scene.java:170)
at javafx.scene.Scene$ScenePulseListener.pulse(Scene.java:2186)
at com.sun.javafx.tk.Toolkit.firePulse(Toolkit.java:363)
at com.sun.javafx.tk.quantum.QuantumToolkit.pulse(QuantumToolkit.java:461)
at com.sun.javafx.tk.quantum.QuantumToolkit$9.run(QuantumToolkit.java:330)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication$3$1.run(GtkApplication.java:89)
at java.lang.Thread.run(Thread.java:724)

Any suggestions as to where I'm messing up?

Many thanks in advance.....
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Error trace from your question

Regarding the error posted in your question, I don't know the exact cause. You are probably overwriting the default table skin somewhere and setting it to null. In early JavaFX versions (e.g. 2.0) it was pretty easy to do this (all you had to do was override the standard style class for a control). However in later JavaFX versions (2.2+) it is pretty hard to achieve this kind of error where the skin is null (as overriding the standard style class for a control will not set the -fx-skin css value for the control to null). Make sure you are running a recent JavaFX version (e.g. 2.2.45+).

Advice for solving your issues

My advice would be to use the source code from the official JavaFX TableView tutorial as the starting point for your table and customize that table to display the information you want. Now that tutorial does not use FXML, and really that is fine. As you are having issues with your current implementation and don't really know what it going wrong. Instead strip out the stuff which you don't need to get your basic concept working (like FXML), and gradually modify something which you know already works until it does what you want in the way you want to do it. So, once you get your app working with plain Java programming, you can add FXML back in again and make it work with that technology. Work from an sscce. If you get stuck at any way along the way in the process, then post your sscce (make sure it is self contained and executable) back to the forum and you will likely receive further help.

Media Player Sample

See the StackOverflow question Java Music Player: Song information and playing.

It's not exactly the same as what you want to achieve, but perhaps it will be useful. What the answer to that question does is introspect on the meta data in the media track to extract embedded information in the media file around album art, artist etc. and then display the information in a table (name/value pair) format.

As you want to display data field types across the top of your table in the column headers rather than down the side of the table in rows, it is probably not a good fit for your situation, but hopefully it provides some insights into creating a simple media player for JavaFX.
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic