java - How can I communicate which object (within an ArrayList) a clicked node is attributed? -


i making javafx form program. form data handled using arraylist of pages arraylists of nodes, objects containing gui element (label) , it's data members.
so:

main declaration

private final arraylist<arraylist<formnode>> form = new arraylist<>();  private final arraylist<formnode> page = new arraylist<>();  int currentnode = 0;  //index of active node 

object class

public class formnode {      private string nodename;     private boolean visible;     private boolean editable;     private label nodegui;      //constructor...sets...gets...methods  } 

when node initialized, added pane , assigned event handlers via separate class. trying have program communicate object active clicking on node associated it, can flagged active node.

something (not actual code, pseudo of need):

the user clicks on desired label (node) in gui, calls...

nodegui.setonmousepressed(new eventhandler<mouseevent>() {     @override public int handle(mouseevent mouseevent) {        --- call method assign value ---         currentnode = thisnodesindex;       }   }); 

the idea return index of formnode object in nested page arraylist assign currentnode value.

right works fine, accessing index trouble. data accessed label (x, y, height, width, etc) need recognized member of object can manipulate other attributes. (i.e nodename, visible, etc).

any ideas?

i don't know if understand asking, try this.

@override public void handle(event evt) {    system.out.println(((control)evt.getsource()).getid()); } 

in case:

nodegui.setonmousepressed(new eventhandler<mouseevent>() {     @override     public int handle(mouseevent mouseevent) {         //--- call method assign value ---         currentnode = thisnodesindex;         system.out.println(((control)mouseevent.getsource()).getid());     } }); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -