I need to improve this by using switch
statement in which I want to set the text and setFullScreen
. Is there any more elegant way to implement this?
final String change[] =
{
"Full Screen", "Exit Full Screen"
};
final MenuItem fullScreen = MenuItemBuilder.create().text(change[0]).build();
fullScreen.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent e)
{
fullScreen.setText((fullScreen.getText().equals(change[0])) ? change[1] : change[0]);
if (fullScreen.getText().equals(change[0]))
{
primaryStage.setFullScreen(false);
}
else
{
primaryStage.setFullScreen(true);
}
}
});
view.getItems().add(fullScreen);