Anchorpane
This commit is contained in:
parent
f3b770e972
commit
48a8902a52
13 changed files with 133 additions and 12 deletions
44
Code/ost/_05_layouts/src/main/java/com/example/App.java
Normal file
44
Code/ost/_05_layouts/src/main/java/com/example/App.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package com.example;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
* JavaFX App with AnchorPane layout
|
||||
*/
|
||||
public class App extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) {
|
||||
// Create AnchorPane
|
||||
AnchorPane anchorPane = new AnchorPane();
|
||||
|
||||
// Create Controll button
|
||||
Button controlButton = new Button("Button");
|
||||
AnchorPane.setTopAnchor(controlButton, 50.0);
|
||||
AnchorPane.setLeftAnchor(controlButton, 50.0);
|
||||
AnchorPane.setRightAnchor(controlButton, 10.0);
|
||||
AnchorPane.setBottomAnchor(controlButton, 10.0);
|
||||
|
||||
// Create Button 1
|
||||
Button button1 = new Button("Button 1");
|
||||
AnchorPane.setTopAnchor(button1, 10.0);
|
||||
AnchorPane.setLeftAnchor(button1, 10.0);
|
||||
|
||||
// Add buttons to the pane
|
||||
anchorPane.getChildren().addAll(controlButton, button1);
|
||||
|
||||
// Set up the Scene with AnchorPane
|
||||
Scene scene = new Scene(anchorPane, 640, 480);
|
||||
stage.setTitle("Hauptfenster with AnchorPane");
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.example;
|
||||
|
||||
public class SystemInfo {
|
||||
|
||||
public static String javaVersion() {
|
||||
return System.getProperty("java.version");
|
||||
}
|
||||
|
||||
public static String javafxVersion() {
|
||||
return System.getProperty("javafx.version");
|
||||
}
|
||||
|
||||
}
|
4
Code/ost/_05_layouts/src/main/java/module-info.java
Normal file
4
Code/ost/_05_layouts/src/main/java/module-info.java
Normal file
|
@ -0,0 +1,4 @@
|
|||
module com.example {
|
||||
requires javafx.controls;
|
||||
exports com.example;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue