Menu Pilihan:
iToonTV Cartoon
(5)
iToonTV Comic
(1)
iToonTV Game
(1)
iToonTV Music
(1)
iToonTV News
(17)
iToonTV Shorts
(3)
JavaFX Tips and Tricks: Invoking JavaFX Functions from Java
- Create a Java interface
 - Extend the interface with a JavaFX class, implementing any functions defined by the interface
 - Obtain a reference to, and call a function of, the JavaFX class defined by the interface
 
Here are snippets of the code that I created yesterday in the context of the steps listed above:
Create the Java interface
public interface UniverseHandler {
  public void onSphereClicked(SphereBranch sphereBranch);
}
 
Extend the interface with a JavaFX class, implementing any functions defined by the interface
public class WindshieldModel extends UniverseHandler {
  ...model code omitted...
  /**
   * This is called when user clicks a sphere on the 3D Canvas
   */
  public override function onSphereClicked(sphereBranch:SphereBranch) {
    curSphereBranch = sphereBranch;
  }
}
 
Obtain a reference to, and call a function of, the JavaFX class defined by the interface
universeHandler.onSphereClicked(currentSphereBranch);
The universeHandler was passed into the constructor of the Java class.
Thanks again to InteractiveMesh.org for their lightweight 3D canvas and classes that enable JavaFX/Java 3D integration!
Subscribe to:
Post Comments (Atom)
Yang Sering Dibaca:
- 
Installation Install JavaFX SDK Download JavaFX SDK for Windows or Mac Os X . Follow the installation instructions. Ins...
 - 
If you have watched Japanese anime or school dramas then you probably have heard the famous bell melody played in schools to signal the end ...
 
0 comments: