From 0b4e9e850e63a979546932724e6e598fbcd6fb2e Mon Sep 17 00:00:00 2001 From: marcusferl Date: Sun, 10 May 2020 08:23:05 +0200 Subject: [PATCH] 123 --- Event oder Filter/.classpath | 7 ++ Event oder Filter/.gitignore | 1 + Event oder Filter/.project | 23 ++++ .../.settings/org.eclipse.jdt.core.prefs | 12 ++ Event oder Filter/build.fxbuild | 8 ++ Event oder Filter/src/application/Main.java | 66 +++++++++++ .../src/application/application.css | 1 + Login mit Java Fx/src/Login.java | 108 +++++++++++++++--- 8 files changed, 213 insertions(+), 13 deletions(-) create mode 100644 Event oder Filter/.classpath create mode 100644 Event oder Filter/.gitignore create mode 100644 Event oder Filter/.project create mode 100644 Event oder Filter/.settings/org.eclipse.jdt.core.prefs create mode 100644 Event oder Filter/build.fxbuild create mode 100644 Event oder Filter/src/application/Main.java create mode 100644 Event oder Filter/src/application/application.css diff --git a/Event oder Filter/.classpath b/Event oder Filter/.classpath new file mode 100644 index 0000000..3b2e843 --- /dev/null +++ b/Event oder Filter/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Event oder Filter/.gitignore b/Event oder Filter/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Event oder Filter/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Event oder Filter/.project b/Event oder Filter/.project new file mode 100644 index 0000000..7b76114 --- /dev/null +++ b/Event oder Filter/.project @@ -0,0 +1,23 @@ + + + Event oder Filter + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + org.eclipse.jdt.core.javanature + + diff --git a/Event oder Filter/.settings/org.eclipse.jdt.core.prefs b/Event oder Filter/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ec1937b --- /dev/null +++ b/Event oder Filter/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,12 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Event oder Filter/build.fxbuild b/Event oder Filter/build.fxbuild new file mode 100644 index 0000000..33f4f43 --- /dev/null +++ b/Event oder Filter/build.fxbuild @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Event oder Filter/src/application/Main.java b/Event oder Filter/src/application/Main.java new file mode 100644 index 0000000..7d2900f --- /dev/null +++ b/Event oder Filter/src/application/Main.java @@ -0,0 +1,66 @@ +package application; + +import javafx.application.Application; +import javafx.event.EventHandler; +import javafx.stage.Stage; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.BorderPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Circle; + +public class Main extends Application { + @Override + public void start(Stage primaryStage) { + try { + + Circle kreis = new Circle(20); + kreis.setFill(Color.BLUE); + kreis.setTranslateX(200); + kreis.setTranslateY(200); + + Group root = new Group(); + root.getChildren().add(kreis); + + Scene scene = new Scene(root, 400, 400); + scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); + primaryStage.setScene(scene); + primaryStage.show(); + + EventHandler eventHandler1 = new EventHandler() { + + @Override + public void handle(MouseEvent event) { + kreis.setFill(Color.RED); + System.out.println("Filter aufgerufen"); + + } + }; + + EventHandler eventHandler2 = new EventHandler() { + + @Override + public void handle(MouseEvent event) { + kreis.setScaleX(2); + kreis.setScaleY(2); + System.out.println("Handler aufgerufen"); + + } + + }; + + kreis.addEventFilter(MouseEvent.MOUSE_CLICKED, eventHandler1); + kreis.addEventHandler(MouseEvent.MOUSE_CLICKED, eventHandler2); + + + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void main(String[] args) { + launch(args); + } +} diff --git a/Event oder Filter/src/application/application.css b/Event oder Filter/src/application/application.css new file mode 100644 index 0000000..83d6f33 --- /dev/null +++ b/Event oder Filter/src/application/application.css @@ -0,0 +1 @@ +/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */ \ No newline at end of file diff --git a/Login mit Java Fx/src/Login.java b/Login mit Java Fx/src/Login.java index 9251517..dc5a19f 100644 --- a/Login mit Java Fx/src/Login.java +++ b/Login mit Java Fx/src/Login.java @@ -1,11 +1,16 @@ import javafx.application.Application; +import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.PasswordField; import javafx.scene.control.TextField; +import javafx.scene.input.KeyCode; +import javafx.scene.input.KeyEvent; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.stage.Stage; @@ -14,47 +19,124 @@ public class Login extends Application { @Override public void start(Stage primaryStage) throws Exception { try { - + Label loginLabel = new Label("Login:"); loginLabel.setTranslateX(20); loginLabel.setTranslateY(20); - + TextField eingabeBenutzername = new TextField("Benutzername"); eingabeBenutzername.setTranslateX(60); eingabeBenutzername.setTranslateY(60); eingabeBenutzername.setMaxHeight(100); eingabeBenutzername.setMaxWidth(100); - + PasswordField eingabePasswort = new PasswordField(); eingabePasswort.setTranslateX(60); eingabePasswort.setTranslateY(100); eingabePasswort.setMaxHeight(100); eingabePasswort.setMaxWidth(100); - + Button loginButton = new Button("Klicken"); loginButton.setTranslateX(80); loginButton.setTranslateY(140); - - //================================================ - // - //================================================ - - Group rootLogin = new Group(); - + rootLogin.getChildren().add(loginLabel); rootLogin.getChildren().add(eingabeBenutzername); rootLogin.getChildren().add(eingabePasswort); rootLogin.getChildren().add(loginButton); - - + Scene loginScene = new Scene(rootLogin, 400, 400); loginScene.setFill(Color.AQUA); primaryStage.setScene(loginScene); primaryStage.show(); primaryStage.setTitle("LOGIN"); + // ================================================ + // + // ================================================ + + EventHandler eventHandler = new EventHandler() { + + @Override + public void handle(MouseEvent event) { + String name = eingabeBenutzername.getText(); + String pw = eingabePasswort.getText(); + + if (name.equals("marcus") && pw.equals("1234")) { + + Label label1 = new Label("Login erfolgreich"); + + Stage stage = new Stage(); + HBox root = new HBox(); + root.getChildren().add(label1); + + Scene loginBereich = new Scene(root, 400, 400); + + stage.setScene(loginBereich); + stage.show(); + + } else { + Label label1 = new Label("Login fehlgeschlagen"); + + Stage stage = new Stage(); + HBox root = new HBox(); + root.getChildren().add(label1); + + Scene loginBereich = new Scene(root, 400, 400); + + stage.setScene(loginBereich); + stage.show(); + + } + + } + }; + + loginButton.addEventHandler(MouseEvent.MOUSE_CLICKED, eventHandler); + + eingabePasswort.setOnKeyPressed(new EventHandler() { + + @Override + public void handle(KeyEvent event) { + if (event.getCode().equals(KeyCode.ENTER)) { + + String name = eingabeBenutzername.getText(); + String pw = eingabePasswort.getText(); + + if (name.equals("marcus") && pw.equals("1234")) { + + Label label1 = new Label("Login erfolgreich"); + + Stage stage = new Stage(); + HBox root = new HBox(); + root.getChildren().add(label1); + + Scene loginBereich = new Scene(root, 400, 400); + stage.setScene(loginBereich); + stage.show(); + + } else { + Label label1 = new Label("Login fehlgeschlagen"); + + Stage stage = new Stage(); + HBox root = new HBox(); + root.getChildren().add(label1); + + Scene loginBereich = new Scene(root, 400, 400); + + stage.setScene(loginBereich); + stage.show(); + + } + + } + + } + + }); + } catch (Exception e) { e.printStackTrace(); }