Skip to main content

CSS and Controls

1 reply [Last post]
kram
Offline
Joined: 2007-10-23

I have been learning about the CSS part of JavaFX, which seems like a great idea, but Im just wondering something.

If I have a custom control, which extends CustomNode, that, in the create() method returns a Group of nodes, such as a heap of different lines, and rectangles etc...

How would I apply a CSS style to an internal node of that group (i.e. one of those internal rectangles)? I cant seem to get it to work just using the styleClass properties, although maybe my CSS declarations are wrong, anyone had any experience with this?

Thanks Heaps!
Mark

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kram
Offline
Joined: 2007-10-23

Ok, so after a little more testing, I have found that you can indeed do what I wanted, Im not sure why my earlier tests did nothing, but now they are working.

I have a similar setup to this:

[code]
public class MyOwnControl extends CustomNode {
public override function create():Node{

var yAxisLine = Line {
startX: 10,
startY: 10,
endX: 100,
endY: 500
styleClass: "yAxisLine"
}

return Group{ content: [ yAxisLine ] }
}
}
[/code]

[b]Note, keep in mind that the +yAxisLine+ is an inner property of the returned Group[/b]

Then inside the CSS sheet, I have this:

[code]
"mytestingpackage.MyOwnControl" .yAxisLine {
stroke: BLACK;
}
[/code]

I hope this helps anyone else with a similar issue