java - JavaFX Split Menu Button Arrow Trigger Event -


i have splitmenubutton, , can't seem find way trigger event when user clicks arrow next button.

i dropdown fill items database when dropdown arrow clicked.

i not sure event can that, , can not find info on either.

short answer: register listener showing property.

import javafx.application.application; import javafx.beans.property.integerproperty; import javafx.beans.property.simpleintegerproperty; import javafx.scene.scene; import javafx.scene.control.menuitem; import javafx.scene.control.splitmenubutton; import javafx.scene.layout.borderpane; import javafx.stage.stage;  public class splitmenubuttontest extends application {      @override     public void start(stage primarystage) {          integerproperty count = new simpleintegerproperty();          splitmenubutton splitmenubutton = new splitmenubutton();         splitmenubutton.settext("action");         splitmenubutton.showingproperty().addlistener((obs, wasshowing, isnowshowing) -> {             if (isnowshowing) {                 int c = count.get() + 1;                 count.set(c);                 splitmenubutton.getitems().clear();                 (int choice = 1; choice <= 3; choice++) {                     menuitem mi = new menuitem("choice "+choice+" (" + c + ")");                     splitmenubutton.getitems().add(mi);                 }             }         });          borderpane root = new borderpane(null, splitmenubutton, null, null, null);         primarystage.setscene(new scene(root, 350, 150));         primarystage.show();     }      public static void main(string[] args) {         launch(args);     } } 

sort of aside, i'm not sure idea. database connections typically long-running processes (i.e. long enough visually noticeable in ui environment). if run on fx application thread, you're going block ui doing while data retrieved, , that's right @ moment user has tried something. of course, if run background task, menu popup previous data, , later update once data downloaded. recommend finding way populate before user requests it.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -