Post render event in JavaFX

前端 未结 1 1824
借酒劲吻你
借酒劲吻你 2020-12-11 10:34

I\'m trying to add a click event listener to the label of all column-headers of a TableView, as follows:

for (final Node header : tblView.lookupAll(\".column         


        
相关标签:
1条回答
  • 2020-12-11 10:59

    There is a WINDOW_SHOWN event in javafx.stage.WindowEvents. That is not (imo) "Post render event" but you can utilize it in similar manner, by adding an event handler to the Stage (which extends from Window).

    In the initialize method of controller class, get the primary stage and then:

    stage.addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() {
        @Override
        public void handle(WindowEvent window) {
            Platform.runLater(new Runnable() {
                @Override
                public void run() {
                    addListenerToColumnHeaders();
                }
            });
        }
    });
    

    Hope this helps, since didn't try myself.

    0 讨论(0)
提交回复
热议问题