backup
This commit is contained in:
88
2/Lenj/Kraftstoffverbrauch.java
Normal file
88
2/Lenj/Kraftstoffverbrauch.java
Normal file
@@ -0,0 +1,88 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.scene.control.*;
|
||||
import je.NumberField;
|
||||
import javafx.scene.text.*;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.event.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* Beschreibung
|
||||
*
|
||||
* @version 1.0 vom 06.11.2024
|
||||
* @author
|
||||
*/
|
||||
|
||||
public class Kraftstoffverbrauch extends Application {
|
||||
// Anfang Attribute
|
||||
private NumberField kmField = new NumberField();
|
||||
private NumberField kraftstoffField = new NumberField();
|
||||
private Button bRechnen = new Button();
|
||||
private Label lErgebnis = new Label();
|
||||
// Ende Attribute
|
||||
|
||||
public void start(Stage primaryStage) {
|
||||
Pane root = new Pane();
|
||||
Scene scene = new Scene(root, 268, 224);
|
||||
// Anfang Komponenten
|
||||
|
||||
kmField.setLayoutX(8);
|
||||
kmField.setLayoutY(24);
|
||||
kmField.setPrefHeight(24);
|
||||
kmField.setPrefWidth(80);
|
||||
kmField.setFont(Font.font("Dialog", 11));
|
||||
kmField.setPromptText("Km");
|
||||
kmField.setText("56");
|
||||
root.getChildren().add(kmField);
|
||||
kraftstoffField.setLayoutX(128);
|
||||
kraftstoffField.setLayoutY(24);
|
||||
kraftstoffField.setPrefHeight(24);
|
||||
kraftstoffField.setPrefWidth(80);
|
||||
kraftstoffField.setFont(Font.font("Dialog", 11));
|
||||
kraftstoffField.setPromptText("l");
|
||||
kraftstoffField.setText("10");
|
||||
root.getChildren().add(kraftstoffField);
|
||||
bRechnen.setLayoutX(72);
|
||||
bRechnen.setLayoutY(64);
|
||||
bRechnen.setPrefHeight(24);
|
||||
bRechnen.setPrefWidth(80);
|
||||
bRechnen.setText("Rechnen");
|
||||
bRechnen.setOnAction(
|
||||
(event) -> {bRechnen_Action(event);}
|
||||
);
|
||||
bRechnen.setFont(Font.font("Dialog", 11));
|
||||
root.getChildren().add(bRechnen);
|
||||
lErgebnis.setLayoutX(16);
|
||||
lErgebnis.setLayoutY(112);
|
||||
lErgebnis.setPrefHeight(24);
|
||||
lErgebnis.setPrefWidth(248);
|
||||
lErgebnis.setText("");
|
||||
lErgebnis.setFont(Font.font("Dialog", 11));
|
||||
root.getChildren().add(lErgebnis);
|
||||
// Ende Komponenten
|
||||
|
||||
primaryStage.setOnCloseRequest(e -> System.exit(0));
|
||||
primaryStage.setTitle("Kraftstoffverbrauch");
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
} // end of public Kraftstoffverbrauch
|
||||
|
||||
// Anfang Methoden
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
} // end of main
|
||||
|
||||
public void bRechnen_Action(Event evt) {
|
||||
double gefahreneKm = kmField.getDouble();
|
||||
double kraftstoffmenge = kraftstoffField.getDouble();
|
||||
|
||||
lErgebnis.setText("Ergebniss: " + ((kraftstoffmenge/gefahreneKm)*100));
|
||||
|
||||
} // end of bRechnen_Action
|
||||
|
||||
// Ende Methoden
|
||||
} // end of class Kraftstoffverbrauch
|
||||
Reference in New Issue
Block a user