final Image resImage = RS.img(RS.IMG_SKIN_RESTORE);
maxBtn.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
final double stageY = Utils.isMac() ? stage.getY() - 22 : stage.getY(); // TODO Workaround for RT-13980
final Screen screen = Screen.getScreensForRectangle(stage.getX(), stageY, 1, 1).get(0);
Rectangle2D bounds = screen.getVisualBounds();
if (bounds.getMinX() == stage.getX() && bounds.getMinY() == stageY &&
bounds.getWidth() == stage.getWidth() && bounds.getHeight() == stage.getHeight()) {
if (backupWindowBounds != null) {
stage.setX(backupWindowBounds.getMinX());
stage.setY(backupWindowBounds.getMinY());
stage.setWidth(backupWindowBounds.getWidth());
stage.setHeight(backupWindowBounds.getHeight());
maxBtn.setImage(maxImage);
}
} else {
backupWindowBounds = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
final double newStageY = Utils.isMac() ? screen.getVisualBounds().getMinY() + 22 : screen.getVisualBounds().getMinY(); // TODO Workaround for RT-13980
stage.setX(screen.getVisualBounds().getMinX());
stage.setY(newStageY);
stage.setWidth(screen.getVisualBounds().getWidth());
stage.setHeight(screen.getVisualBounds().getHeight());
maxBtn.setImage(resImage);
}
}
});
final ImageView closeBtn = newTitleBarButton(RS.IMG_SKIN_CLOSE, 0.7, 0);