Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to pass Objects from Java App to JavaFX Application

unixjedi-OracleFeb 6 2015 — edited Feb 6 2015

Hello,

New to the JavaFX. I have a Java Swing Application. I am trying to use the TreeViewer in JavaFX since it seems to be a bit better to use and less confusing.

Any help is appreciated.

Thanks

I have my Java app calling my treeviewer JavaFX as

-- Java Application --

public class EPMFrame extends JFrame {

Customer _custObj

....

private void categoryAction(ActionEvent e)   // method called by Toolbar

{

        ocsCategoryViewer ocsFX;    //javaFX treeviewer

        ocsFX = new ocsCategoryViewer();    // need to pass in the Customer Object to this Not seeing how to do it.

                                              // tried ocsFX = new ocsCategoryViewer(_custObj) ;    nothing happened even when set this as a string with a value

}

public class ocsCategoryViewer extends Application {

String _customer;

@Override

    public void start(Stage primaryStage) {

     TreeView <String> ocsTree;

     TreeItem <String> root , subcat;

    

 

        

  TreeItem <String> root = new TreeItem <String> ("/");

        root.setExpanded(true);

      

         ocsTree = new TreeView <String> (root);

         buildTree();     // this uses the Customer Object.

        StackPane stkp_root = new StackPane();

        stkp_root.getChildren().add(btn);

        stkp_root.getChildren().add(ocsTree);

        Scene scene = new Scene(stkp_root, 300, 250);

      

        primaryStage.setTitle("Tree Category Viewer");

        primaryStage.setScene(scene);

        primaryStage.show();

}

    public static void main(String[] args) {

        _customer = args[0];      // temporarily trying to pass in string.

        launch(args);

    }

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2015
Added on Feb 6 2015
2 comments
1,003 views