B4J Question TableView-style causes StackOverflowError

tcgoh

Active Member
Licensed User
Longtime User
Hi,

I am have a java.lang.StackOverflowError when the style on the tableView was set to
-fx-font-size: 20;

This happen when I tried to update the table with a combox SelectedIndexChanged.

Anyone having this problem?
attached zip file for reference

Thanks
 

Attachments

I added the 1.db file from the zip to the files tab and I'm getting a No such Table : Students error.
 
Upvote 0
OK got past that, I put it in objects, it had created an empty db as you had create if necessary set to true. Now, I'll have a look.
 
Upvote 0
Strange, if you use a style sheet as attached, it all works fine. I can't tell you why it fails using style.

The more I use style sheets the more I like them, it's well worth it if you don't already.

I've changed your code slightly to save looking up the selected value, as it's passed to the sub.
 

Attachments

Upvote 0
I've just had a quick look on Google, it seems that there are a few reports of similar things using javafx and style, so it doesn't appear to be b4j specific.
 
Upvote 0
Hi Steve,

Thank you for the reply and for showing me the style sheet. Its work for the tableview. How do I use the ccs for the combobox?

Thanks
 
Upvote 0
When you create a node with the designer, an item is added to the Style Class list automatically, two in the case of the combo box. They are listed in light gray text. You can access the classes with a '.' so on a new line in the style sheet put:

Code:
.combo-box (-fx-font-size:20;}

or whatever css style you want. You can add multiple classes to the Style Class and make your own groupings, just add the same class name to multiple nodes, and they will all get the styles you declare for the class.

You can also access the items via the ID with a '#' so:

Code:
#combo1 {-fx-font-size:20;}

should also do it. but as there are two classes generated, I'm not sure which element of the combo box will get the style possibly both.

Be careful of this one if you are capturing input from a number of TextAreas or other nodes using the sender, as they will need to have the same id. It may be simpler to stick to classes.

If you haven't already seen it, the javafx css reference is here.
 
Upvote 0
The combo box seems to be more complicated than that, there are a few subclasses to look at. You'll also need to move the css stylesheet from the tableview (where it is now) to the AnchorPane, then it will apply to all of the anchorpane's children.
 
Upvote 0
Wow, that was fun! There seems to be a problem reported long ago (2010) whereby the dropdown called combobox popup(style class combo-box-popup) is not accessible from a stylesheet added to anywhere but the scene.

Working out how to do that was also interesting. but the amended app attached manages it. The style sheet needs to be in the objects folder, but also in the Files folder for Scene Builder so you can see the rest of your styles, so it copies the file from the project files folder to the object folder and then applies it to the scene.

There are a few substructures (documentation here that will be helpful). The 3rd line in the css .combo-box ... sets the size of the font for the combo-box header.

I'm not sure how you'd go about having two combo boxes with different styles though, it doesn't seem to respond to the id (#combo1)
 
Last edited:
Upvote 0
wow thanks. But I can't run your file due 'Dim SLCSS As SLLoadStyleSheet'
Am I missing any libraries ?
 
Upvote 0
Back
Top