List of usage examples for javafx.scene Group getChildren
@Override
public ObservableList<Node> getChildren()
From source file:Main.java
License:asdf
@Override public void start(Stage primaryStage) { User user = new User(); Group root = new Group(); Scene scene = new Scene(root, 320, 100); primaryStage.setScene(scene);//from w ww .j ava2 s .c o m Text userName = new Text(); userName.textProperty().bind(user.userNameProperty()); PasswordField passwordField = new PasswordField(); passwordField.setPromptText("Password"); user.passwordProperty().bind(passwordField.textProperty()); // user hits the enter key passwordField.setOnAction(actionEvent -> { if (accessGranted.get()) { System.out.println("granted access:" + user.getUserName()); System.out.println("password:" + user.getPassword()); Platform.exit(); } else { primaryStage.setTitle("no access"); } }); passwordField.textProperty().addListener((obs, ov, nv) -> { boolean granted = passwordField.getText().equals(MY_PASS); accessGranted.set(granted); if (granted) { primaryStage.setTitle(""); } }); VBox formLayout = new VBox(4); formLayout.getChildren().addAll(userName, passwordField); formLayout.setLayoutX(12); formLayout.setLayoutY(12); root.getChildren().addAll(formLayout); primaryStage.show(); }
From source file:be.makercafe.apps.makerbench.editors.GCodeEditor.java
/** * Draws a line in 3D between 2 3D points on the given group. * // w ww.j a v a 2 s . co m * @param origin * Origin point * @param target * Target point * @return 3D line (cylinder) between to points */ private Cylinder drawLine3D(Group group, Point3D origin, Point3D target, Material color) { if (color == null) { color = MATERIAL_BLACK; // default to orange } Point3D yAxis = new Point3D(0, 1, 0); Point3D diff = target.subtract(origin); double height = diff.magnitude(); Point3D mid = target.midpoint(origin); Translate moveToMidpoint = new Translate(mid.getX(), mid.getY(), mid.getZ()); Point3D axisOfRotation = diff.crossProduct(yAxis); double angle = Math.acos(diff.normalize().dotProduct(yAxis)); Rotate rotateAroundCenter = new Rotate(-Math.toDegrees(angle), axisOfRotation); Cylinder line = new Cylinder(1, height); line.setMaterial(color); line.getTransforms().addAll(moveToMidpoint, rotateAroundCenter); if (group != null) { group.getChildren().add(line); } return line; }
From source file:org.wandora.application.gui.topicpanels.webview.WebViewPanel.java
private void initFX(final JFXPanel fxPanel) { Group group = new Group(); Scene scene = new Scene(group); fxPanel.setScene(scene);/*from w w w . j av a 2 s .c o m*/ webView = new WebView(); if (javaFXVersionInt >= 8) { webView.setScaleX(1.0); webView.setScaleY(1.0); //webView.setFitToHeight(false); //webView.setFitToWidth(false); //webView.setZoom(javafx.stage.Screen.getPrimary().getDpi() / 96); } group.getChildren().add(webView); int w = this.getWidth(); int h = this.getHeight() - 34; webView.setMinSize(w, h); webView.setMaxSize(w, h); webView.setPrefSize(w, h); // Obtain the webEngine to navigate webEngine = webView.getEngine(); webEngine.locationProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) { if (newValue.endsWith(".pdf")) { try { int a = WandoraOptionPane.showConfirmDialog(Wandora.getWandora(), "Open PDF document in external application?", "Open PDF document in external application?", WandoraOptionPane.YES_NO_OPTION); if (a == WandoraOptionPane.YES_OPTION) { Desktop dt = Desktop.getDesktop(); dt.browse(new URI(newValue)); } } catch (Exception e) { } } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { urlTextField.setText(newValue); } }); } } }); webEngine.titleProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, final String newValue) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { title = newValue; } }); } }); webEngine.setOnAlert(new EventHandler<WebEvent<java.lang.String>>() { @Override public void handle(WebEvent<String> t) { if (t != null) { String str = t.getData(); if (str != null && str.length() > 0) { WandoraOptionPane.showMessageDialog(Wandora.getWandora(), str, "Javascript Alert", WandoraOptionPane.PLAIN_MESSAGE); } } } }); webEngine.setConfirmHandler(new Callback<String, Boolean>() { @Override public Boolean call(String msg) { int a = WandoraOptionPane.showConfirmDialog(Wandora.getWandora(), msg, "Javascript Alert", WandoraOptionPane.YES_NO_OPTION); return (a == WandoraOptionPane.YES_OPTION); } }); webEngine.setPromptHandler(new Callback<PromptData, String>() { @Override public String call(PromptData data) { String a = WandoraOptionPane.showInputDialog(Wandora.getWandora(), data.getMessage(), data.getDefaultValue(), "Javascript Alert", WandoraOptionPane.QUESTION_MESSAGE); return a; } }); webEngine.setCreatePopupHandler(new Callback<PopupFeatures, WebEngine>() { @Override public WebEngine call(PopupFeatures features) { if (informPopupBlocking) { WandoraOptionPane.showMessageDialog(Wandora.getWandora(), "A javascript popup has been blocked. Wandora doesn't allow javascript popups in Webview topic panel.", "Javascript popup blocked", WandoraOptionPane.PLAIN_MESSAGE); } informPopupBlocking = false; return null; } }); webEngine.setOnVisibilityChanged(new EventHandler<WebEvent<Boolean>>() { @Override public void handle(WebEvent<Boolean> t) { if (t != null) { Boolean b = t.getData(); if (informVisibilityChanges) { WandoraOptionPane.showMessageDialog(Wandora.getWandora(), "A browser window visibility change has been blocked. Wandora doesn't allow visibility changes of windows in Webview topic panel.", "Javascript visibility chnage blocked", WandoraOptionPane.PLAIN_MESSAGE); informVisibilityChanges = false; } } } }); webEngine.getLoadWorker().stateProperty().addListener(new ChangeListener<State>() { @Override public void changed(ObservableValue ov, State oldState, State newState) { if (newState == Worker.State.SCHEDULED) { //System.out.println("Scheduled!"); startLoadingAnimation(); } if (newState == Worker.State.SUCCEEDED) { Document doc = webEngine.getDocument(); try { Transformer transformer = TransformerFactory.newInstance().newTransformer(); //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); // transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(System.out, "UTF-8"))); StringWriter stringWriter = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(stringWriter)); webSource = stringWriter.toString(); } catch (Exception ex) { ex.printStackTrace(); } stopLoadingAnimation(); } else if (newState == Worker.State.CANCELLED) { //System.out.println("Cancelled!"); stopLoadingAnimation(); } else if (newState == Worker.State.FAILED) { webEngine.loadContent(failedToOpenMessage); stopLoadingAnimation(); } } }); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Split Views"); Group root = new Group(); Scene scene = new Scene(root, 350, 250, Color.WHITE); SplitPane splitPane = new SplitPane(); splitPane.prefWidthProperty().bind(scene.widthProperty()); splitPane.prefHeightProperty().bind(scene.heightProperty()); VBox leftArea = new VBox(10); HBox rowBox = new HBox(20); final Text leftText = TextBuilder.create().text("Left ").translateX(20).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 20)).build(); rowBox.getChildren().add(leftText);//from w w w . j a v a2s . c o m leftArea.getChildren().add(rowBox); leftArea.setAlignment(Pos.CENTER); SplitPane splitPane2 = new SplitPane(); splitPane2.setOrientation(Orientation.VERTICAL); splitPane2.prefWidthProperty().bind(scene.widthProperty()); splitPane2.prefHeightProperty().bind(scene.heightProperty()); HBox centerArea = new HBox(); final Text upperRight = TextBuilder.create().text("Text").x(100).y(50).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build(); centerArea.getChildren().add(upperRight); HBox rightArea = new HBox(); final Text lowerRight = TextBuilder.create().text("Lower Right").x(100).y(50).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build(); rightArea.getChildren().add(lowerRight); splitPane2.getItems().add(centerArea); splitPane2.getItems().add(rightArea); splitPane.getItems().add(leftArea); splitPane.getItems().add(splitPane2); ObservableList<SplitPane.Divider> dividers = splitPane.getDividers(); for (int i = 0; i < dividers.size(); i++) { dividers.get(i).setPosition((i + 1.0) / 3); } HBox hbox = new HBox(); hbox.getChildren().add(splitPane); root.getChildren().add(hbox); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Person.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); Group root = new Group(); Scene scene = new Scene(root, 500, 250, Color.WHITE); // create a grid pane GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);//from ww w .j av a2 s. c o m gridpane.setVgap(10); ObservableList<Person> leaders = FXCollections.observableArrayList(); leaders.add(new Person("A", "B", "C")); leaders.add(new Person("D", "E", "F")); final ListView<Person> leaderListView = new ListView<Person>(leaders); leaderListView.setPrefWidth(150); leaderListView.setPrefHeight(150); // leaderListView.setCellFactory(new Callback<ListView<Person>, ListCell<Person>>() { public ListCell<Person> call(ListView<Person> param) { final Label leadLbl = new Label(); final Tooltip tooltip = new Tooltip(); final ListCell<Person> cell = new ListCell<Person>() { @Override public void updateItem(Person item, boolean empty) { super.updateItem(item, empty); if (item != null) { leadLbl.setText(item.getAliasName()); setText(item.getFirstName() + " " + item.getLastName()); tooltip.setText(item.getAliasName()); setTooltip(tooltip); } } }; // ListCell return cell; } }); // setCellFactory gridpane.add(leaderListView, 0, 1); leaderListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() { public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) { System.out.println("selection changed"); } }); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("ObservableLists"); Group root = new Group(); Scene scene = new Scene(root, 400, 250, Color.WHITE); GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);/*from w w w . j a va 2s. co m*/ gridpane.setVgap(10); Label candidatesLbl = new Label("Left"); GridPane.setHalignment(candidatesLbl, HPos.CENTER); gridpane.add(candidatesLbl, 0, 0); Label heroesLbl = new Label("Right"); gridpane.add(heroesLbl, 2, 0); GridPane.setHalignment(heroesLbl, HPos.CENTER); final ObservableList<String> lefts = FXCollections.observableArrayList("A", "B", "C"); final ListView<String> leftListView = new ListView<String>(lefts); leftListView.setPrefWidth(150); leftListView.setPrefHeight(150); gridpane.add(leftListView, 0, 1); final ObservableList<String> rights = FXCollections.observableArrayList(); final ListView<String> rightListView = new ListView<String>(rights); rightListView.setPrefWidth(150); rightListView.setPrefHeight(150); gridpane.add(rightListView, 2, 1); Button sendRightButton = new Button(">"); sendRightButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { String item = leftListView.getSelectionModel().getSelectedItem(); if (item != null) { leftListView.getSelectionModel().clearSelection(); lefts.remove(item); rights.add(item); } } }); Button sendLeftButton = new Button("<"); sendLeftButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent event) { String item = rightListView.getSelectionModel().getSelectedItem(); if (item != null) { rightListView.getSelectionModel().clearSelection(); rights.remove(item); lefts.add(item); } } }); VBox vbox = new VBox(5); vbox.getChildren().addAll(sendRightButton, sendLeftButton); gridpane.add(vbox, 1, 1); GridPane.setConstraints(vbox, 1, 1, 1, 2, HPos.CENTER, VPos.CENTER); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { stage.setTitle("Hello Drag And Drop"); Group root = new Group(); Scene scene = new Scene(root, 400, 200); scene.setFill(Color.LIGHTGREEN); final Text source = new Text(50, 100, "DRAG ME"); source.setScaleX(2.0);/*w w w.j ava 2s . c o m*/ source.setScaleY(2.0); final Text target = new Text(250, 100, "DROP HERE"); target.setScaleX(2.0); target.setScaleY(2.0); source.setOnDragDetected(new EventHandler<MouseEvent>() { public void handle(MouseEvent event) { /* drag was detected, start drag-and-drop gesture*/ System.out.println("onDragDetected"); /* allow any transfer mode */ Dragboard db = source.startDragAndDrop(TransferMode.ANY); /* put a string on dragboard */ ClipboardContent content = new ClipboardContent(); content.putString(source.getText()); db.setContent(content); event.consume(); } }); target.setOnDragOver(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* data is dragged over the target */ System.out.println("onDragOver"); /* accept it only if it is not dragged from the same node * and if it has a string data */ if (event.getGestureSource() != target && event.getDragboard().hasString()) { /* allow for both copying and moving, whatever user chooses */ event.acceptTransferModes(TransferMode.COPY_OR_MOVE); } event.consume(); } }); target.setOnDragEntered(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* the drag-and-drop gesture entered the target */ System.out.println("onDragEntered"); /* show to the user that it is an actual gesture target */ if (event.getGestureSource() != target && event.getDragboard().hasString()) { target.setFill(Color.GREEN); } event.consume(); } }); target.setOnDragExited(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* mouse moved away, remove the graphical cues */ target.setFill(Color.BLACK); event.consume(); } }); target.setOnDragDropped(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* data dropped */ System.out.println("onDragDropped"); /* if there is a string data on dragboard, read it and use it */ Dragboard db = event.getDragboard(); boolean success = false; if (db.hasString()) { target.setText(db.getString()); success = true; } /* let the source know whether the string was successfully * transferred and used */ event.setDropCompleted(success); event.consume(); } }); source.setOnDragDone(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* the drag-and-drop gesture ended */ System.out.println("onDragDone"); /* if the data was successfully moved, clear it */ if (event.getTransferMode() == TransferMode.MOVE) { source.setText(""); } event.consume(); } }); root.getChildren().add(source); root.getChildren().add(target); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(final Stage stage) { stage.setTitle("Xylophone"); camOffset.getChildren().add(cam);/* www . ja va 2 s . c o m*/ resetCam(); final Scene scene = new Scene(camOffset, 800, 600, true); scene.setFill(new RadialGradient(225, 0.85, 300, 300, 500, false, CycleMethod.NO_CYCLE, new Stop[] { new Stop(0f, Color.BLUE), new Stop(1f, Color.LIGHTBLUE) })); scene.setCamera(new PerspectiveCamera()); final AudioClip bar1Note = new AudioClip(Main.class.getResource("audio/Note1.wav").toString()); final AudioClip bar2Note = new AudioClip(Main.class.getResource("audio/Note2.wav").toString()); final AudioClip bar3Note = new AudioClip(Main.class.getResource("audio/Note3.wav").toString()); final AudioClip bar4Note = new AudioClip(Main.class.getResource("audio/Note4.wav").toString()); final AudioClip bar5Note = new AudioClip(Main.class.getResource("audio/Note5.wav").toString()); final AudioClip bar6Note = new AudioClip(Main.class.getResource("audio/Note6.wav").toString()); final AudioClip bar7Note = new AudioClip(Main.class.getResource("audio/Note7.wav").toString()); final AudioClip bar8Note = new AudioClip(Main.class.getResource("audio/Note8.wav").toString()); Group rectangleGroup = new Group(); rectangleGroup.getTransforms().add(shear); rectangleGroup.setDepthTest(DepthTest.ENABLE); double xStart = 260.0; double xOffset = 30.0; double yPos = 300.0; double zPos = 0.0; double barWidth = 22.0; double barDepth = 7.0; // Base1 Cube base1Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base1Cube.setTranslateX(xStart + 135); base1Cube.setTranslateZ(yPos + 20.0); base1Cube.setTranslateY(11.0); base1Cube.setScaleX(barWidth * 11.5); base1Cube.setScaleZ(10.0); base1Cube.setScaleY(barDepth * 2.0); // Base2 Cube base2Cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base2Cube.setTranslateX(xStart + 135); base2Cube.setTranslateZ(yPos - 20.0); base2Cube.setTranslateY(11.0); base2Cube.setScaleX(barWidth * 11.5); base2Cube.setScaleZ(10.0); base2Cube.setScaleY(barDepth * 2.0); // Bar1 Cube bar1Cube = new Cube(1.0, Color.PURPLE, 1.0); bar1Cube.setTranslateX(xStart + 1 * xOffset); bar1Cube.setTranslateZ(yPos); bar1Cube.setScaleX(barWidth); bar1Cube.setScaleZ(100.0); bar1Cube.setScaleY(barDepth); // Bar2 Cube bar2Cube = new Cube(1.0, Color.BLUEVIOLET, 1.0); bar2Cube.setTranslateX(xStart + 2 * xOffset); bar2Cube.setTranslateZ(yPos); bar2Cube.setScaleX(barWidth); bar2Cube.setScaleZ(95.0); bar2Cube.setScaleY(barDepth); // Bar3 Cube bar3Cube = new Cube(1.0, Color.BLUE, 1.0); bar3Cube.setTranslateX(xStart + 3 * xOffset); bar3Cube.setTranslateZ(yPos); bar3Cube.setScaleX(barWidth); bar3Cube.setScaleZ(90.0); bar3Cube.setScaleY(barDepth); // Bar4 Cube bar4Cube = new Cube(1.0, Color.GREEN, 1.0); bar4Cube.setTranslateX(xStart + 4 * xOffset); bar4Cube.setTranslateZ(yPos); bar4Cube.setScaleX(barWidth); bar4Cube.setScaleZ(85.0); bar4Cube.setScaleY(barDepth); // Bar5 Cube bar5Cube = new Cube(1.0, Color.GREENYELLOW, 1.0); bar5Cube.setTranslateX(xStart + 5 * xOffset); bar5Cube.setTranslateZ(yPos); bar5Cube.setScaleX(barWidth); bar5Cube.setScaleZ(80.0); bar5Cube.setScaleY(barDepth); // Bar6 Cube bar6Cube = new Cube(1.0, Color.YELLOW, 1.0); bar6Cube.setTranslateX(xStart + 6 * xOffset); bar6Cube.setTranslateZ(yPos); bar6Cube.setScaleX(barWidth); bar6Cube.setScaleZ(75.0); bar6Cube.setScaleY(barDepth); // Bar7 Cube bar7Cube = new Cube(1.0, Color.ORANGE, 1.0); bar7Cube.setTranslateX(xStart + 7 * xOffset); bar7Cube.setTranslateZ(yPos); bar7Cube.setScaleX(barWidth); bar7Cube.setScaleZ(70.0); bar7Cube.setScaleY(barDepth); // Bar8 Cube bar8Cube = new Cube(1.0, Color.RED, 1.0); bar8Cube.setTranslateX(xStart + 8 * xOffset); bar8Cube.setTranslateZ(yPos); bar8Cube.setScaleX(barWidth); bar8Cube.setScaleZ(65.0); bar8Cube.setScaleY(barDepth); bar1Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar1Note.play(); } }); bar2Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar2Note.play(); } }); bar3Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar3Note.play(); } }); bar4Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar4Note.play(); } }); bar5Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar5Note.play(); } }); bar6Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar6Note.play(); } }); bar7Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar7Note.play(); } }); bar8Cube.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { bar8Note.play(); } }); rectangleGroup.getChildren().addAll(base1Cube, base2Cube, bar1Cube, bar2Cube, bar3Cube, bar4Cube, bar5Cube, bar6Cube, bar7Cube, bar8Cube); rectangleGroup.setScaleX(2.5); rectangleGroup.setScaleY(2.5); rectangleGroup.setScaleZ(2.5); cam.getChildren().add(rectangleGroup); double halfSceneWidth = 375; // scene.getWidth()/2.0; double halfSceneHeight = 275; // scene.getHeight()/2.0; cam.p.setX(halfSceneWidth); cam.ip.setX(-halfSceneWidth); cam.p.setY(halfSceneHeight); cam.ip.setY(-halfSceneHeight); frameCam(stage, scene); scene.setOnMousePressed(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { mousePosX = me.getX(); mousePosY = me.getY(); mouseOldX = me.getX(); mouseOldY = me.getY(); //System.out.println("scene.setOnMousePressed " + me); } }); scene.setOnMouseDragged(new EventHandler<MouseEvent>() { public void handle(MouseEvent me) { mouseOldX = mousePosX; mouseOldY = mousePosY; mousePosX = me.getX(); mousePosY = me.getY(); mouseDeltaX = mousePosX - mouseOldX; mouseDeltaY = mousePosY - mouseOldY; if (me.isAltDown() && me.isShiftDown() && me.isPrimaryButtonDown()) { double rzAngle = cam.rz.getAngle(); cam.rz.setAngle(rzAngle - mouseDeltaX); } else if (me.isAltDown() && me.isPrimaryButtonDown()) { double ryAngle = cam.ry.getAngle(); cam.ry.setAngle(ryAngle - mouseDeltaX); double rxAngle = cam.rx.getAngle(); cam.rx.setAngle(rxAngle + mouseDeltaY); } else if (me.isShiftDown() && me.isPrimaryButtonDown()) { double yShear = shear.getY(); shear.setY(yShear + mouseDeltaY / 1000.0); double xShear = shear.getX(); shear.setX(xShear + mouseDeltaX / 1000.0); } else if (me.isAltDown() && me.isSecondaryButtonDown()) { double scale = cam.s.getX(); double newScale = scale + mouseDeltaX * 0.01; cam.s.setX(newScale); cam.s.setY(newScale); cam.s.setZ(newScale); } else if (me.isAltDown() && me.isMiddleButtonDown()) { double tx = cam.t.getX(); double ty = cam.t.getY(); cam.t.setX(tx + mouseDeltaX); cam.t.setY(ty + mouseDeltaY); } } }); scene.setOnKeyPressed(new EventHandler<KeyEvent>() { public void handle(KeyEvent ke) { if (KeyCode.A.equals(ke.getCode())) { resetCam(); shear.setX(0.0); shear.setY(0.0); } if (KeyCode.F.equals(ke.getCode())) { frameCam(stage, scene); shear.setX(0.0); shear.setY(0.0); } if (KeyCode.SPACE.equals(ke.getCode())) { if (stage.isFullScreen()) { stage.setFullScreen(false); frameCam(stage, scene); } else { stage.setFullScreen(true); frameCam(stage, scene); } } } }); stage.setScene(scene); stage.show(); }