Java Code Examples for javafx.scene.layout.HBox#setTranslateY()
The following examples show how to use
javafx.scene.layout.HBox#setTranslateY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorButtonSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ColorButtonSample() { HBox hBox = new HBox(); hBox.setSpacing(5); for(int i=0; i<7; i++) { Button b = new Button("Color"); b.setStyle("-fx-base: rgb("+(10*i)+","+(20*i)+","+(10*i)+");"); hBox.getChildren().add(b); } HBox hBox2 = new HBox(); hBox2.setSpacing(5); hBox2.setTranslateY(30); Button red = new Button("Red"); red.setStyle("-fx-base: red;"); Button orange = new Button("Orange"); orange.setStyle("-fx-base: orange;"); Button yellow = new Button("Yellow"); yellow.setStyle("-fx-base: yellow;"); Button green = new Button("Green"); green.setStyle("-fx-base: green;"); Button blue = new Button("Blue"); blue.setStyle("-fx-base: rgb(30,170,255);"); Button indigo = new Button("Indigo"); indigo.setStyle("-fx-base: blue;"); Button violet = new Button("Violet"); violet.setStyle("-fx-base: purple;"); hBox2.getChildren().add(red); hBox2.getChildren().add(orange); hBox2.getChildren().add(yellow); hBox2.getChildren().add(green); hBox2.getChildren().add(blue); hBox2.getChildren().add(indigo); hBox2.getChildren().add(violet); VBox vBox = new VBox(20); vBox.getChildren().addAll(hBox,hBox2); getChildren().add(vBox); }
Example 2
Source File: ColorButtonSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public ColorButtonSample() { HBox hBox = new HBox(); hBox.setSpacing(5); for(int i=0; i<7; i++) { Button b = new Button("Color"); b.setStyle("-fx-base: rgb("+(10*i)+","+(20*i)+","+(10*i)+");"); hBox.getChildren().add(b); } HBox hBox2 = new HBox(); hBox2.setSpacing(5); hBox2.setTranslateY(30); Button red = new Button("Red"); red.setStyle("-fx-base: red;"); Button orange = new Button("Orange"); orange.setStyle("-fx-base: orange;"); Button yellow = new Button("Yellow"); yellow.setStyle("-fx-base: yellow;"); Button green = new Button("Green"); green.setStyle("-fx-base: green;"); Button blue = new Button("Blue"); blue.setStyle("-fx-base: rgb(30,170,255);"); Button indigo = new Button("Indigo"); indigo.setStyle("-fx-base: blue;"); Button violet = new Button("Violet"); violet.setStyle("-fx-base: purple;"); hBox2.getChildren().add(red); hBox2.getChildren().add(orange); hBox2.getChildren().add(yellow); hBox2.getChildren().add(green); hBox2.getChildren().add(blue); hBox2.getChildren().add(indigo); hBox2.getChildren().add(violet); VBox vBox = new VBox(20); vBox.getChildren().addAll(hBox,hBox2); getChildren().add(vBox); }
Example 3
Source File: FroggerApp.java From FXTutorials with MIT License | 5 votes |
private void checkState() { for (Node car : cars) { if (car.getBoundsInParent().intersects(frog.getBoundsInParent())) { frog.setTranslateX(0); frog.setTranslateY(600 - 39); return; } } if (frog.getTranslateY() <= 0) { timer.stop(); String win = "YOU WIN"; HBox hBox = new HBox(); hBox.setTranslateX(300); hBox.setTranslateY(250); root.getChildren().add(hBox); for (int i = 0; i < win.toCharArray().length; i++) { char letter = win.charAt(i); Text text = new Text(String.valueOf(letter)); text.setFont(Font.font(48)); text.setOpacity(0); hBox.getChildren().add(text); FadeTransition ft = new FadeTransition(Duration.seconds(0.66), text); ft.setToValue(1); ft.setDelay(Duration.seconds(i * 0.15)); ft.play(); } } }
Example 4
Source File: MKXMenuApp.java From FXTutorials with MIT License | 4 votes |
private Parent createContent() { Pane root = new Pane(); root.setPrefSize(900, 600); Rectangle bg = new Rectangle(900, 600); ContentFrame frame1 = new ContentFrame(createLeftContent()); ContentFrame frame2 = new ContentFrame(createMiddleContent()); ContentFrame frame3 = new ContentFrame(createRightContent()); HBox hbox = new HBox(15, frame1, frame2, frame3); hbox.setTranslateX(120); hbox.setTranslateY(50); MenuItem itemExit = new MenuItem("EXIT"); itemExit.setOnActivate(() -> System.exit(0)); menuBox = new VBox(10, new MenuItem("ONE PLAYER"), new MenuItem("TWO PLAYER"), new MenuItem("ONLINE"), new MenuItem("FACTION"), new MenuItem("KRYPT"), new MenuItem("OPTIONS"), new MenuItem("EXTRAS*"), itemExit); menuBox.setAlignment(Pos.TOP_CENTER); menuBox.setTranslateX(360); menuBox.setTranslateY(300); Text about = new Text("MKXMenuApp\n\tby\n AlmasB"); about.setTranslateX(50); about.setTranslateY(500); about.setFill(Color.WHITE); about.setFont(FONT); about.setOpacity(0.2); getMenuItem(0).setActive(true); root.getChildren().addAll(bg, hbox, menuBox, about); return root; }