• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is there some documentation that shows you a standard way of altering Java code to FXML ?

 
Ranch Hand
Posts: 101
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
Is there some guideline for converting Java code to FXML ?
I mean Is there some set of rules I could learn that would allow me to create the tags and nodes by
Just looking at the original Java code ?
 
Rancher
Posts: 387
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.

The closest resource you will find is studying:
https://docs.oracle.com/javase/8/javafx/api/javafx/fxml/doc-files/introduction_to_fxml.html
Which you have probably already read.

Don't try to write a Java Code => FXML converter, it is not possible to do so for arbitrary Java code.

Java is a general purpose programming language.
FXML is just a declarative markup for generation of objects (usually JavaFX nodes).
As FXML does not, and never will, support all of the functionality of a general Java program, you could never write a converter to convert the complete functionality of the Java program to FXML.

FXML works by using reflection to create instances Java of classes and to call methods on those instances, based upon the definitions supplied in an FXML document.

Generally, for simple object creation and construction (not complex application logic), it is possible to translate that from Java to FXML, though there are no automated tools to do it, you have to do it manually.

The rule of thumb to do so, would be that each new object in Java becomes an element in the FXML and each setter invoked on that object in Java becomes an attribute of the associated element in FXML.
Event handlers, are prefixed with #.
That is a very simplistic outline, but would be enough to convert some basic object instantiations from Java to FXML.

For instance:

Would become:
 
It's a beautiful day in this neighborhood - Fred Rogers. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic