Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
passing objects as arguments using namedArg annotation in javafx 8

how do one pass a non-string object as argment using @namedArg in javafx? I cannot find a single nutshell example regarding this question online!

I am currently trying to instantiate a InlineCssTextArea from RichTextFX wrapped in a VirtualizedScrollPane - please have a look at this source code:

public VirtualizedScrollPane(@NamedArg("content") V content) {
  [...]
}

where the custom type V is extending Node. In my case, I want to pass InlineCssTextArea as V. Doing this programmatically is pretty easy:

InlineCssTextArea area = new InlineCssTextArea();
Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(area)), 600, 400);

but translating that to FXML is quite challenging. I have already tried a few things, like fx:factory based on the official oracle fxml tutorial:

<VirtualizedScrollPane fx:factory="content">
  <InlineCssTextArea />
</VirtualizedScrollPane>

or how @namedArg suggests, as argument:

<VirtualizedScrollPane content="InlineCssTextArea" />

-or-

<VirtualizedScrollPane content="<InlineCssTextArea />" />

Is there a fxml solution for this problem?

my question is based on the the following answer from James D: What is the purpose of @NamedArg annotation in javaFX 8?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You basically need to pass a value for an argument called content. The two ways to pass a value for an argument in FXML are as an attribute: content="..." or using a property element. Using an attribute only works if you can pass a string which the FXML loader knows how to convert to the appropriate value (i.e. if the value is a string or a primitive type), which isn't the case here. Using a property element you just nest an element whose name is the property name and nest the value inside it:

<VirtualizedScrollPane>
    <content>
        <InlineCssTextArea />
    </content>
</VirtualizedScrollPane>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!