• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A single addEventHandler assigned to multiple objects

 
derek nickerson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a simple application using FXML and Scene Builder. My goal is to add a text area to the scene after a button is pressed. The text area will simply be sticky note that I would like to be able to drag-and-drop into any of the 5 flow panes that are placed in an HBox. My program works fine now, but there are too many redundancies that I'd like to streamline.

What is the best way to condense the code?

Code below is in Controller class and adds text area


Following code placed within initialize method of controller:


 
derek nickerson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any help please?
 
Paul Clapham
Sheriff
Posts: 21558
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a JavaFX expert so I may not have the correct event handler types, but you just create an event handler object and then assign it to whatever components you like.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic