/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package main; import com.sun.javafx.tk.quantum.QuantumRenderer; import java.sql.Time; import javafx.animation.Timeline; import javafx.animation.TranslateTransition; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Side; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ContextMenu; import javafx.scene.control.MenuItem; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; import javafx.stage.StageStyle; import javafx.util.Duration; /** * * @author Alessio */ public class MultiThreading extends Application { /** * @param args the command line arguments */ public static void main(String[] args) { QuantumRenderer.getInstance().setCorePoolSize(2); QuantumRenderer.getInstance().setMaximumPoolSize(4); launch(args); } @Override public void start(Stage primaryStage) { primaryStage.setTitle("Test"); primaryStage.initStyle(StageStyle.DECORATED); final Button btn = new Button(); btn.setText("Click Me!"); btn.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { Stage stage = new Stage(StageStyle.TRANSPARENT); stage.setWidth(300); stage.setHeight(250); stage.setScene(new Scene(new Group(), Color.ORANGE)); stage.show(); /*ContextMenu contextMenu = new ContextMenu(); contextMenu.getItems().add(new MenuItem("Item 1")); contextMenu.show(btn, Side.BOTTOM, 0 ,0);*/ } }); Rectangle rect = new Rectangle(20, 20, 40, 30); rect.setFill(Color.BLUE); Pane pane = new Pane(); pane.setPrefSize(300, 250); pane.getChildren().add(rect); TranslateTransition animation = new TranslateTransition(Duration.millis(500), rect); animation.setToX(100); animation.setAutoReverse(true); animation.setCycleCount(Timeline.INDEFINITE); animation.play(); StackPane root = new StackPane(); root.getChildren().add(pane); root.getChildren().add(btn); primaryStage.setScene(new Scene(root, 300, 250, Color.RED)); primaryStage.show(); } }