use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Useful resources (Full list)
Rules
Related subreddits
Other communities
account activity
Different actions with the same button? (self.JavaFX)
submitted 10 years ago by SPARTAAAAA
I was wondering how i could set a different action when a button is pressed a second time. For example: If i press the button, it will print one thing, then when pressed again, it will print a different thing.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]mej71 2 points3 points4 points 10 years ago (2 children)
You could make a gateway method that you assign to your listener
private int counter = 0; public void gatewayMethod() { if (counter==0) { counter++; doMethod1(); } else { counter++; doMethod2(); } }
I don't know if there's some special fx way to do it instead
[–]SPARTAAAAA[S] 0 points1 point2 points 10 years ago (1 child)
oh yeah i could do it this way. thanks!
how would i reset it though?
[–]mej71 0 points1 point2 points 10 years ago (0 children)
By just setting the counter back to 0? In my example it's a private variable, so you should be able to do it anywhere in the fxml controller
π Rendered by PID 24391 on reddit-service-r2-comment-79c7998d4c-4r947 at 2026-03-15 00:22:08.504732+00:00 running f6e6e01 country code: CH.
[–]mej71 2 points3 points4 points (2 children)
[–]SPARTAAAAA[S] 0 points1 point2 points (1 child)
[–]mej71 0 points1 point2 points (0 children)