/* * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ //package hello; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; import javafx.animation.Timeline; import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.util.Duration; import javafx.scene.control.Button; import javafx.scene.layout.HBox; public class HelloIconify extends Application { boolean isMax = false; boolean isFS = false; @Override public void start(Stage stage) { // WORKS: stage.initStyle(StageStyle.DECORATED); // FAILS: stage.initStyle(StageStyle.UNDECORATED); // FAILS: stage.initStyle(StageStyle.TRANSPARENT); stage.initStyle(StageStyle.TRANSPARENT); //=========== stage.setTitle("Hello Iconify"); final Scene scene = new Scene(new Group(), 600, 450); //scene.setFill(Color.LIGHTGREEN); scene.setFill(Color.color(0.5647059f, 0.93333334f, 0.5647059f, 0.60)); final Rectangle rect = new Rectangle(); rect.setX(25); rect.setY(40); rect.setWidth(100); rect.setHeight(50); rect.setFill(Color.RED); ((Group)scene.getRoot()).getChildren().add(rect); Button button = new Button("iconify"); button.setOnAction(e -> { stage.setIconified(true); }); Button fsbutton = new Button("fullscreen"); fsbutton.setOnAction(e -> { isFS = !isFS; System.out.println("stage.setFullScreen("+isFS+")"); stage.setFullScreen(isFS); }); Button mbutton = new Button("maximize"); mbutton.setOnAction(e -> { isMax = !isMax; System.out.println("stage.setstage.setMaximized("+isMax+")"); stage.setMaximized(isMax); }); HBox root = new HBox(); root.getChildren().add(button); root.getChildren().add(fsbutton); root.getChildren().add(mbutton); ((Group)scene.getRoot()).getChildren().add(root); stage.setScene(scene); stage.show(); final Timeline timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); final KeyValue kv = new KeyValue(rect.xProperty(), 200); final KeyFrame kf = new KeyFrame(Duration.millis(500), kv); timeline.getKeyFrames().add(kf); timeline.play(); System.out.println(Double.POSITIVE_INFINITY * 2); } /** * @param args the command line arguments */ public static void main(String[] args) { Application.launch(args); } }