One of the things, that I could never get to work with a Swing application is the full screen mode on a Linux (Ubuntu, Mint) machine. There was always a panel (menu bar) that would be in the way and hide part of the application. Furthermore it is inherently more difficult to handle the proper layout. Therefore I did a quick test with JavaFX to see if these issues have been overcome.
And they have. I reused the example with the scalable ImageViewPane and added a mouse click handler on the stage which simply toggles between full screen and windowed mode.
private boolean fullsreen = false;
@Override
public void start(final Stage primaryStage) {
try {
Image img = new Image( getClass().getResource("kajak4_small.png").openStream());
ImageViewPane imageViewPane = new ImageViewPane(new ImageView(img));
StackPane root = new StackPane();
root.getChildren().add(imageViewPane);
root.setOnMousePressed(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent t) {
primaryStage.setFullScreen(!fullsreen);
fullsreen = !fullsreen;
}
});
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("FullscreenTest");
primaryStage.setScene(scene);
primaryStage.show();
} catch (IOException ex) {
Logger.getLogger(FullscreenTest.class.getName()).log(Level.SEVERE, null, ex);
}
}