@FXML public void openHome(ActionEvent event) throws IOException { Node node = (Node) event.getSource(); final Stage stage = (Stage) node.getScene().getWindow(); Parent root = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml")); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); stage.centerOnScreen(); final Parent home = FXMLLoader.load(getClass().getResource("/fxml/Homepage.fxml")); final Scene hScene = new Scene(home); root.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.ESCAPE) { System.out.println("Key Pressed: " + ke.getCode() + " Made by ShaMaster"); stage.setScene(hScene); } } }); }
@Override public void start(Stage stage) throws Exception { VBox root = new VBox(); Label counterLabel = new Label(""); ToggleButton startStopButton = new ToggleButton(); // Multicast the ToggleButton's true/false selected state Observable<Boolean> selectedStates = JavaFxObservable.valuesOf(startStopButton.selectedProperty()) .publish() .autoConnect(2); // Using switchMap() with ToggleButton's selected state willdrive // whether to kick off an Observable.interval(), // or dispose() it by switching to empty Observable selectedStates.switchMap(selected -> { if (selected) return Observable.interval(1, TimeUnit.MILLISECONDS); else return Observable.empty(); }).observeOn(JavaFxScheduler.platform()) // Observe on JavaFX UI thread .map(Object::toString) .subscribe(counterLabel::setText); // Change ToggleButton's text depending on its state selectedStates.subscribe(selected -> startStopButton.setText(selected ? "STOP" : "START") ); root.getChildren().addAll(counterLabel, startStopButton); stage.setScene(new Scene(root)); stage.show(); }
@Override public void start(Stage primaryStage) { try { Scene scene = new Scene(new LoginView().getView()); scene.getStylesheets().add("css/application.css"); primaryStage.setTitle(Constants.APP_NAME); primaryStage.setResizable(false); primaryStage.setScene(scene); primaryStage.getIcons().add(Constants.APP_LOGO); primaryStage.show(); createShortcut(); } catch(Exception e) { e.printStackTrace(); } }
@Override public void start(Stage primaryStage) { GameChooser gameManager = new GameChooser(primaryStage); primaryStage.setScene(makeScene()); primaryStage.setFullScreenExitHint(""); primaryStage.setFullScreenExitKeyCombination(null); primaryStage.show(); primaryStage.setFullScreen(true); Animation myAnimation = makeAnimation(myActor, 100, 200, 100); // start animation myAnimation.play(); Animation myAnimation1 = makeAnimation(myActor1, 100, 200, 100); // start animation myAnimation1.play(); Animation myAnimation2 = makeAnimation(myActor2,100,240,140); // start animation myAnimation2.play(); }
private void editDrug(Drug drug) { FXMLLoader fXMLLoader = new FXMLLoader(getClass().getResource("/view/drug/EditDrug.fxml")); try { Parent root = fXMLLoader.load(); EditDrugController controller = fXMLLoader.getController(); controller.setDrugId(drug.getId()); controller.taNote.setText(drug.getNote()); controller.tfTradeName.setText(drug.getName()); controller.tfGenericName.setText(drug.getGenricName()); Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.setTitle("Edit Drug"); stage.setScene(new Scene(root)); stage.show(); } catch (IOException ex) { Logger.getLogger(PatientsController.class.getName()).log(Level.SEVERE, null, ex); } }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("2DTree Demo"); Group root = new Group(); Canvas canvas = new Canvas(XSIZE, YSIZE); gc = canvas.getGraphicsContext2D(); canvas.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { gc.fillOval(e.getX(), e.getY(), 3, 3); double[] coords = { e.getX() / XSIZE, e.getY() / YSIZE }; instance.insert(new HyperPoint(coords)); instance.draw(); } }); root.getChildren().add(canvas); Scene sc = new Scene(root); primaryStage.setScene(sc); primaryStage.show(); }
@Override public void start(Stage primaryStage) { try { Parent root = FXMLLoader.load(getClass().getResource("mainView.fxml")); Scene scene = new Scene(root, 1280, 720); initData(primaryStage); // TODO: inserire l'icona dell'applicazione // rilascio tutte le risorse allocate prima della chiusura dell'applicazione primaryStage.setOnCloseRequest(MainController::performCleanUp); scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } catch(Exception e) { e.printStackTrace(); } }
public void remover() { botaoRemover.setOnMouseClicked(e -> { //CadastroDisciplina c = new CadastroDisciplina(); //Pane telaCadastroDisciplinas; Stage stage = (Stage) botaoRemover.getScene().getWindow(); RemoverProfessor var = new RemoverProfessor(); try { //SubmenuProfessor.pane = FXMLLoader.load(SubmenuProfessor.class.getResource("submenuProfessorFXML.fxml")); //var.getPane().setPrefHeight(560); //var.getPane().setPrefWidth(600); //SubmenuProfessor.pane.setCenter(var.getPane()); //SubmenuProfessor.pane.setCenterShape(false); //stage.setScene(new Scene(SubmenuProfessor.pane)); //stage.setTitle("Menu Professor"); //stage.setResizable(false); ScreenManager.getInstance().showRemoveProf(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } }); }
@Override public void start(Stage stage) throws Exception { VBox root = new VBox(); ListView<String> listView = new ListView<>(); Button refreshButton = new Button("REFRESH"); JavaFxObservable.actionEventsOf(refreshButton) .observeOn(Schedulers.io()) .flatMapSingle(a -> Observable.fromArray(getResponse("https://goo.gl/S0xuOi") .split("\\r?\\n") ).toList() ).observeOn(JavaFxScheduler.platform()) .subscribe(list -> listView.getItems().setAll(list)); root.getChildren().addAll(listView, refreshButton); stage.setScene(new Scene(root)); stage.show(); }
public TemplateBox(String name) { setTitle(name); initModality(Modality.NONE); String style = LocalFont.getDefaultFontCSS(); getDialogPane().setStyle( style ); Stage stage = (Stage) getDialogPane().getScene().getWindow(); stage.setAlwaysOnTop(checkForceOnTop()); stage.getIcons().add(new Image(App.ICON_URL.toString())); getDialogPane().getButtonTypes().add(new ButtonType(Main.getString("close"), ButtonBar.ButtonData.CANCEL_CLOSE)); openedDialogs.add(this); final TemplateBox thisBox = this; setOnCloseRequest(new EventHandler<DialogEvent>() { @Override public void handle(DialogEvent event) { openedDialogs.remove(thisBox); for(EventHandler<DialogEvent> handler : handlers){ handler.handle(event); } } }); applyStyle(); }
@Override public void start(Stage stage) throws Exception { VBox root = new VBox(); Label label = new Label(""); // Observable with second timer Observable<String> seconds = Observable.interval(1, TimeUnit.SECONDS) .map(i -> i.toString()) .observeOn(JavaFxScheduler.platform()); // Turn Observable into Binding Binding<String> binding = JavaFxObserver.toBinding(seconds); //Bind Label to Binding label.textProperty().bind(binding); root.setMinSize(200, 100); root.getChildren().addAll(label); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); }
/** * Creates a window for adding a new Requirement * * @return newly created Requirement */ public Requirement addRequirement() throws Exception { RequirementController rc = new RequirementController(); // Load in the .fxml file: FXMLLoader loader = new FXMLLoader(getClass().getResource("/View/Requirement.fxml")); loader.setController(rc); Parent root = loader.load(); // Set the scene: Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.setScene(new Scene(root, 550, 260)); stage.setTitle("New Requirement"); stage.resizableProperty().setValue(false); stage.getIcons().add(new Image("file:icon.png")); stage.showAndWait(); // Handle creation of the Account object: if (rc.isSuccess()) return rc.getRequirement(); return null; }
@Override public void start(final Stage primaryStage) throws IOException, UIInitialisationException { stage = primaryStage; primaryStage.setTitle(Hygene.TITLE); primaryStage.initStyle(StageStyle.UNDECORATED); progress = new ProgressBar(); final URL resource = getClass().getResource(PRELOADER_VIEW); final Parent root = FXMLLoader.load(resource); if (root == null) { throw new UIInitialisationException("Root of Preloader could not be found."); } final Scene rootScene = new Scene(root); primaryStage.setScene(rootScene); primaryStage.show(); }
public void editClicked(){ if(lstudname.getText().equals("")) { // Nothing selected. Alert alert = new Alert(AlertType.WARNING); alert.setTitle("No Selection"); alert.setHeaderText("No Lecturer Selected"); alert.setContentText("Please select a Lecturer in the list."); alert.showAndWait(); } else { try { new EditLec().start(new Stage()); EditLec.txtid.setText(lstudname.getText()); } catch (Exception e) { ErrorMessage.display("Launch Error", e.getMessage()+" Application Launch Error"); e.printStackTrace(); } } }
@FXML public void openDownloader(ActionEvent actionEvent) throws IOException { Stage stage = new Stage(); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(this.tableView.getScene().getWindow()); Parent root = FXMLLoader.load(getClass().getResource("/Downloader.fxml")); root.getStylesheets().add(this.getClass().getResource(Main.properties.getProperty("css")).toExternalForm()); javafx.scene.Scene scene = new javafx.scene.Scene(root); stage.setScene(scene); stage.setTitle("鳳凰卓牌譜ダウンロード"); stage.show(); stage.setOnHiding(event -> { this.tableView.getItems().clear(); this.tableView.getItems().addAll(this.databaseService.findAllExistsInfos()); }); }
private HtmlImageExporter(Project project, Path targetFolder, String prefix, OutputFormat outputFormat, Consumer<String> callback) { this.project = project; this.targetFoler = targetFolder; this.prefix = prefix; this.callback = callback; this.outputFormat = outputFormat; stage = new Stage(); browser = new WebView(); browser.setFontSmoothingType(FontSmoothingType.GRAY); ScrollPane scrollPane = new ScrollPane(browser); bar = new ProgressBar(); bar.setMaxWidth(Double.MAX_VALUE); bar.setPadding(new Insets(8)); bar.setProgress(0); VBox vBox = new VBox(bar, scrollPane); Scene scene = new Scene(vBox); stage.setScene(scene); stage.show(); }
@Override public void getClickAction(final Dictionary dictionary, final Stage stage, final TabFactory tabFactory, final DialogFactory dialogFactory) { FileChooser fileChooser = new FileChooser(); fileChooser.getExtensionFilters().add(FileExtensionFilters.MARKDOWN); File file = fileChooser.showOpenDialog(stage); if(file != null){ try { tabFactory.createAndAddNewEditorTab(file); } catch (FileNotFoundException e1) { dialogFactory.buildExceptionDialogBox( dictionary.DIALOG_EXCEPTION_TITLE, dictionary.DIALOG_EXCEPTION_OPENING_MARKDOWN_CONTENT, e1.getMessage(), e1 ).showAndWait(); } } }
public GithubRepoDialogController showGithubRepoDialog(){ GithubRepoDialogController controller = null; try { FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("com/kaanburaksener/octoUML/src/view/fxml/githubRepoDialog.fxml")); AnchorPane page = loader.load(); Stage dialogStage = new Stage(); dialogStage.initModality(Modality.WINDOW_MODAL); dialogStage.initOwner(this.stage); dialogStage.setScene(new Scene(page)); controller = loader.getController(); controller.setDialogStage(dialogStage); dialogStage.showAndWait(); } catch (IOException e){ e.printStackTrace(); } return controller; }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("ServerGUI"); GridPane gridPane = initGridPane(); //server server = new Server(serverConsole); Scene scene = new Scene(gridPane, 400, 400); primaryStage.setScene(scene); primaryStage.show(); primaryStage.setResizable(false); primaryStage.setOnCloseRequest(e -> Platform.exit()); }
protected void parseMenu (Stage stage, MenuBar menuBar, JsonArray jsonArray) { Platform.runLater(() -> { for (int i = 0; i < jsonArray.size(); i++) { //get menu entry JsonObject entry = jsonArray.getJsonObject(i); //get event and title //String event = entry.getString("event"); String title = entry.getString("title"); //create new menu Menu menu = new Menu(title); //add sub menus this.parseSubMenus(menu, entry.getJsonArray("submenus")); //add menu to menu bar menuBar.getMenus().add(menu); } menuBar.prefWidthProperty().bind(stage.widthProperty()); }); }
/** * 设置canvas大小 */ private void setCanvasSize() { try { FXMLLoader fxmlLoader = new FXMLLoader((getClass().getResource("size_chooser.fxml"))); Parent root1 = fxmlLoader.load(); Stage stage = new Stage(DECORATED); stage.setTitle("选择画布"); Scene scene = new Scene(root1); sizeChooser = fxmlLoader.getController(); stage.setScene(scene); stage.showAndWait(); if (sizeChooser.getCanvas() != null) { canvas.setHeight(sizeChooser.getCanvas().getHeight()); canvas.setWidth(sizeChooser.getCanvas().getWidth()); canvas.setLayoutX(450 - canvas.getWidth() / 2); canvas.setLayoutY(300 - canvas.getHeight() / 2); Rectangle rectangle = new Rectangle(canvas.getWidth(), canvas.getHeight()); rectangle.setLayoutX(canvas.getLayoutX()); rectangle.setLayoutY(canvas.getLayoutY()); mainPane.setClip(rectangle); GraphicsContext gc = canvas.getGraphicsContext2D(); gc.setFill(Color.WHITE); gc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight()); } else { //不选择就退出程序 System.exit(0); } } catch (IOException e) { e.printStackTrace(); } }
@Override public void start(Stage rootStage) throws Exception { rootStage.setMaximized(true); main = this; FXMLLoader loader = new FXMLLoader(getClass().getResource("/resources/layouts/main.fxml")); Parent root = loader.load(); Scene rootScene = new Scene(root); rootStage.setTitle("Parallator"); rootController = loader.getController(); rootStage.setScene(rootScene); initMenu(rootStage); rootStage.show(); rootStage.setOnCloseRequest(event -> { if (rootController.getFile() == null || !rootController.isEdited()) return; Alert alert = new Alert(Alert.AlertType.WARNING); alert.setHeaderText("Сохранить перед выходом?"); alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL); Optional<ButtonType> result = alert.showAndWait(); if (result.isPresent() && result.get() == ButtonType.YES) { rootController.save(); } if (result.isPresent() && result.get() == ButtonType.CANCEL) { event.consume(); } }); rootScene.addEventFilter(KeyEvent.KEY_PRESSED, event -> { switch (event.getCode()) { case DOWN: rootController.down(); break; case UP: rootController.up(); break; } }); if (MainConfig.getMainConfig().path() != null) rootController.open(new File(MainConfig.getMainConfig().path())); }
@Override public void start(Stage stage) { stage.setTitle("QuizOff"); stage.setOnCloseRequest(event -> logout()); stage.setScene(new LoginScreen(stage, 640, 720)); stage.setResizable(false); stage.sizeToScene(); stage.show(); }
public void editClicked(){ if(lstudname.getText().equals("")) { // Nothing selected. Alert alert = new Alert(AlertType.WARNING); alert.setTitle("No Selection"); alert.setHeaderText("No Lecturer Selected"); alert.setContentText("Please select a Lecturer in the list."); alert.showAndWait(); } else { try { new EditVisitor().start(new Stage()); EditVisitor.txtid.setText(lstudname.getText()); } catch (Exception e) { ErrorMessage.display("Launch Error", e.getMessage()+" Application Launch Error"); e.printStackTrace(); } } }
@Override public void start(Stage primaryStage) { primaryStage.setTitle("TreeTable View Sample"); primaryStage.setScene(new Scene(new TreeTableSample())); primaryStage.sizeToScene(); primaryStage.show(); TreeTableView<?> treeTableView = (TreeTableView<?>) primaryStage.getScene().getRoot().lookup(".tree-table-view"); treeTableView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); }
@Override public void start(Stage primaryStage) throws Exception { MediaService mediaService = DemoConstants.newMediaService(); AnnotationService annotationService = DemoConstants.newAnnotationService(); Label label = new Label(); Button button = new JFXButton("Browse"); Dialog<Media> dialog = new SelectMediaDialog(annotationService, mediaService, uiBundle); button.setOnAction(e -> { Optional<Media> media = dialog.showAndWait(); media.ifPresent(m -> label.setText(m.getUri().toString())); }); VBox vBox = new VBox(label, button); Scene scene = new Scene(vBox, 400, 200); primaryStage.setScene(scene); primaryStage.show(); primaryStage.setOnCloseRequest(e -> { Platform.exit(); System.exit(0); }); }
@Override public void start(Stage primaryStage) throws Exception { Calendar zurich = new Calendar("Zurich"); CalendarSource calendarSource = new CalendarSource("Weather"); calendarSource.getCalendars().addAll(zurich); MonthSheetView sheetView = new MonthSheetView(); sheetView.setPadding(new Insets(20)); sheetView.setCellFactory(param -> new WeatherCell(param.getView(), param.getDate())); sheetView.getCalendarSources().setAll(calendarSource); sheetView.setContextMenu(null); Scene scene = new Scene(sheetView); primaryStage.setTitle("Weather Calendar"); primaryStage.setScene(scene); primaryStage.setWidth(1300); primaryStage.setHeight(1000); primaryStage.centerOnScreen(); primaryStage.show(); }
@Override public final Node getPanel(Stage stage) { DateControl dateControl = createControl(); control = dateControl; requireNonNull(control, "missing date control"); DeveloperConsole console = new DeveloperConsole(); console.setDateControl(dateControl); if (isSupportingDeveloperConsole()) { MasterDetailPane masterDetailPane = new MasterDetailPane(); masterDetailPane.setMasterNode(wrap(dateControl)); masterDetailPane.setDetailSide(Side.BOTTOM); masterDetailPane.setDetailNode(console); masterDetailPane.setShowDetailNode(true); return masterDetailPane; } return wrap(dateControl); }
@Override public void start(Stage primaryStage) { WeekView root1 = new WeekView(LocalDate.now(), new Calendar()); Stage stage = new Stage(); stage.setScene(new Scene(root1)); stage.setTitle("Fastis"); stage.setMinWidth(100); stage.setMinHeight(100); stage.show(); testLayout(root1); testCalendar(root1); }
/** * Creates the canvas for scrolling and panning. * * @param primaryStage - Stage as given by the start method */ private void setupInterface(Stage primaryStage) { root = new Group(); primaryStage.setTitle("Drone simulator"); primaryStage.setResizable(false); primaryStage.setOnCloseRequest(onCloseEventHandler); Runtime.getRuntime().addShutdownHook(new Thread(() -> onCloseEventHandler.handle(null))); // create canvas canvas = new PannableCanvas(Settings.CANVAS_WIDTH, Settings.CANVAS_HEIGHT); canvas.setId("pane"); canvas.setTranslateX(0); canvas.setTranslateY(0); root.getChildren().add(canvas); double width = Settings.SCENE_WIDTH > Settings.CANVAS_WIDTH ? Settings.CANVAS_WIDTH : Settings.SCENE_WIDTH; double height = Settings.SCENE_HEIGHT > Settings.CANVAS_HEIGHT ? Settings.CANVAS_HEIGHT : Settings.SCENE_HEIGHT; // create scene which can be dragged and zoomed Scene scene = new Scene(root, width, height); SceneGestures sceneGestures = new SceneGestures(canvas); scene.addEventFilter(MouseEvent.MOUSE_PRESSED, sceneGestures.getOnMousePressedEventHandler()); scene.addEventFilter(MouseEvent.MOUSE_DRAGGED, sceneGestures.getOnMouseDraggedEventHandler()); scene.addEventFilter(ScrollEvent.ANY, sceneGestures.getOnScrollEventHandler()); scene.getStylesheets().addAll(this.getClass().getResource("/style.css").toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); canvas.addGrid(); }
@FXML private void mnuUndo(ActionEvent event) { String feedback = new Undo().actionUndo(); Stage MakeATransactionStage = (Stage) btnSignOut.getScene().getWindow(); Alert alert = new Alert(AlertType.INFORMATION); alert.setTitle("Action Successful"); alert.setHeaderText(null); alert.setContentText(feedback); alert.setX(MakeATransactionStage.getX() + 190); alert.setY(MakeATransactionStage.getY() + 190); // initialize(); gmInitialize(); exInitialize(); leInitialize(); bkInitialize(); rocInitialize(); perInitialize(); alert.showAndWait(); }
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Drawing Operations Test"); Group root = new Group(); Canvas canvas = new Canvas(300, 250); GraphicsContext gc = canvas.getGraphicsContext2D(); drawShapes(gc); root.getChildren().add(canvas); primaryStage.setScene(new Scene(root)); primaryStage.show(); }
@Override public void start(Stage stage) throws Exception { WebView view = new WebView(); view.setPrefSize(1800, 1100); view.getEngine().load("https://html5test.netkit/"); Group root = new Group(view); Scene scene = new Scene(root, 1800, 1100); stage.setTitle("Tests :: GeneralTest"); stage.setScene(scene); stage.show(); }
public String getOMapClassName() { if (currentWindow instanceof Stage) { String className = currentWindow.getClass().getName(); Package pkg = currentWindow.getClass().getPackage(); if (pkg == null) { return className; } String pkgName = pkg.getName(); if (!pkgName.startsWith(Stage.class.getPackage().getName())) { return className; } return null; } return null; }
@Override public void start(Stage stage) throws IOException { GridPane gridPane = new GridPane(); gridPane.setAlignment(Pos.CENTER); gridPane.setHgap(10); gridPane.setVgap(10); gridPane.setPadding(new Insets(25, 25, 25, 25)); final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Hour"); yAxis.setLabel("Visits"); final BubbleChart<Number,Number> bubbleChart = new BubbleChart<>(xAxis,yAxis); List<StoreVisit> data = getData(); Integer maxSale = getMaxSale(data); XYChart.Series<Number,Number> series = new XYChart.Series<>(); series.setName("Store Visits"); data.forEach(sv -> { series.getData().add(new XYChart.Data<Number, Number>( sv.hour, sv.visits, (sv.sales/(maxSale * 1d)) * 2 )); }); bubbleChart.getData().add(series); gridPane.add(bubbleChart, 1, 1); Scene scene = new Scene(gridPane, 600, 400); stage.setTitle("Bubble Charts"); stage.setScene(scene); stage.show(); }
@Override public void start(Stage stage) { StackPane pane = new StackPane(circluarPlot); pane.setPadding(new Insets(10)); Scene scene = new Scene(pane); stage.setTitle("Circular Plot"); stage.setScene(scene); stage.show(); }
@Override public void start(Stage primaryStage) { try { VBox root = FXMLLoader.load(getClass().getResource("Main.fxml")); Scene scene = new Scene(root); primaryStage.setScene(scene); primaryStage.setResizable(false); primaryStage.setTitle("Association Rule Generator"); primaryStage.show(); } catch(Exception e) { e.printStackTrace(); } }
/** * Handles logout request, and return the user to the login screen. * @param event The event that trigger this function. * @throws IOException If the fxml was not found. */ @FXML public void logoutUser(ActionEvent event) throws IOException { //Close current window, and go back to login screen Stage stage = (Stage) menuBar.getScene().getWindow(); stage.close(); Stage stage2 = new Stage(); Parent root2 = FXMLLoader.load(getClass().getResource("/dataBaseLogin/MountieLib.fxml")); Scene scene2 = new Scene(root2); stage2.setScene(scene2); stage2.getIcons().add(new Image("images/titleIcon.png")); stage2.initModality(Modality.NONE); stage2.show(); }
@FXML protected void bakersDozenMenuClick() throws IOException { boolean response = ExitWindow.display("Confirm", "Are you sure you would like to exit out of your current game and start a new Baker's Dozen Game?"); if (response) { Stage main = (Stage) _gameMenu.getScene().getWindow(); Parent bakersDozenFXML = FXMLLoader.load(getClass().getResource("/fxml/bakersDozenGame.fxml")); bakersDozenFXML.getStylesheets().add("/stylesheets/bakersDozenGame.css"); Scene bakersDozenScene = new Scene(bakersDozenFXML); main.setScene(bakersDozenScene); main.show(); } }
private void init(Stage primaryStage) { Group root = new Group(); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 260,100)); //create a circle with effect final Circle circle = new Circle(20, Color.rgb(156,216,255)); circle.setEffect(new Lighting()); //create a text inside a circle final Text text = new Text (i.toString()); text.setStroke(Color.BLACK); //create a layout for circle with text inside final StackPane stack = new StackPane(); stack.getChildren().addAll(circle, text); stack.setLayoutX(30); stack.setLayoutY(30); //create a timeline for moving the circle timeline = new Timeline(); timeline.setCycleCount(Timeline.INDEFINITE); timeline.setAutoReverse(true); //one can add a specific action when each frame is started. There are one or more frames during // executing one KeyFrame depending on set Interpolator. timer = new AnimationTimer() { @Override public void handle(long l) { text.setText(i.toString()); i++; } }; //create a keyValue with factory: scaling the circle 2times KeyValue keyValueX = new KeyValue(stack.scaleXProperty(), 2); KeyValue keyValueY = new KeyValue(stack.scaleYProperty(), 2); //create a keyFrame, the keyValue is reached at time 2s Duration duration = Duration.seconds(2); //one can add a specific action when the keyframe is reached EventHandler<ActionEvent> onFinished = new EventHandler<ActionEvent>() { public void handle(ActionEvent t) { stack.setTranslateX(java.lang.Math.random()*200); //reset counter i = 0; } }; KeyFrame keyFrame = new KeyFrame(duration, onFinished , keyValueX, keyValueY); //add the keyframe to the timeline timeline.getKeyFrames().add(keyFrame); root.getChildren().add(stack); }