0


I am currently working with javafx and using CSS for styling.
I want to know whether it is possible to access java class variables in css or not.
For example.
I have a class Size in package constants.

public class Size {
    public static final int VBOX_SPACING = 10;
}

Here is the css file

.vbox {
    -fx-spacing: constants.Size.VBOX_SPACING;
}

This code giving me error (most foolish way to do this).
I just want to know whether it is possible or not.
I don't want to declare variables in css.
Any answer would be really helpful.

1 Answer 1

1

No you can not access any javacode from css

Sign up to request clarification or add additional context in comments.

5 Comments

This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.
@SatelliteSD: In my opinion, this seems to be a perfectly valid answer. The user has asked whether it is possible or not to access Java class variables in CSS and the answer says it can't.
@Harry yes, that is true. My idea while flaggingwas that this is an answer to the question, but not to the problem. --But-- the flagging-text says "answer to the question" literally. So you are right and I am not.
I searched a lot on the internet but didn't find any answer. Thank you guys finally i know now that it is not possible to access java class variables from css (javafx). I just want to ask whether it is possible to create variables of types (int, string) in css (javafx).
@AnkeshKushwah Note that JavaFX 8 provides stylable properties which allow some interaction between CSS and Java code. I'm not very familiar with it, though, and don't know if it could be used to solve your issue. docs.oracle.com/javase/8/javafx/api/javafx/css/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.