Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

button click code?

 
Cody Biggs
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So we are starting java fx, and im beyond lost. I am suppose to take my original code of adding a student, and instructor. Or looking them up in a list, but make that with java fx now.

As far as I know is adding buttons and text fields, but what I dont get is the code that comes after the user would click a button.


So if they were to click the add student button then what?
 
Piet Souris
Rancher
Posts: 1530
33
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must add aan EventHandler to the button, with: button.setOnAction(eventhandler).

See this link: java fx button tutorial
 
Cody Biggs
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok so im just spitballing here. In my setOnAction I should be able to also setTextFields so the user can enter a student last name, first name. Then my code to store that name into a list follows all of that?
 
Knute Snortum
Bartender
Pie
Posts: 2908
62
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it would be easier to create the text fields for last name and first name and the add button all at once.  The user would then enter the name and where they click the button, you can get the text from the text fields and add to the List.  You should also probably check that something was entered in the name fields first.
 
Cody Biggs
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So I want to make sure I did this right. The way I saw it done was that you make the action events method firsts, and then make the buttons and everything for them. So my buttons would just go below all the following code?



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic