my application consists of a TabPane
named tabPane
with, lets say, two Tab
s: firstTab
and secondTab
. Whenever firstTab
is selected, I want the application to be in FSEM
(full-screen exclusive mode
, see documentation); otherwise it should be in normal windowed mode.
My usual way of being notified about which Tab
is active is either
BooleanBinding isFirstTabActive = tabPane.getSelectionModel().
selectedItemProperty().isEqualTo(firstTab);
or
tabPane.getSelectionModel.selectedItemProperty().addListener(...);
Since stage.fullScreenProperty()
is read-only and therefore cannot be binded (as stated in docs), I can not use my first method and do, lets say,
stage.fullScreenProperty().bind(isFirstTabActive) //not working.
Since I am not planning on sigining the application for now and, as the docs state:
Applications can only enter FSEM in response to user input. More specifically, entering is allowed from mouse (Node.mousePressed/mouseReleased/mouseClicked) or keyboard (Node.keyPressed/keyReleased/keyTyped) event handlers.
I can not use the second method either, by doing
tabPane.getSelectionModel.selectedItemProperty().addListener(new ChangeListener<Tab>() {
@Override
public void changed(ObservableValue<? extends Tab> observable, Tab oldValue, Tab newValue) {
stage.setFullScreen(newValue == firstTab);
}
);
because this way the application does not enter FSEM
but only emulated fullscreen mode.
I do know that I can enter FSEM
by creating EventHandler
s which listen to tabPane
events. But this way I had to add two EventHandler
s for both MouseEvent.MOUSE_CLICKED
and KeyEvent.KEY_TYPED
, and the EventHandler
s would have to explicitly find out whats going on ignoring their Event
, like:
tabPane.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
stage.setFullScreen(tabPane.getSelectionModel().getSelectedItem() == firstTab);
}
});
So is this really the way to go here? Or can I do some workaround with the Binding
s? Any suggestions here? Thanks.