Created
October 31, 2015 15:30
-
-
Save KristerV/654a0ba3735e6d538fba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package teema2; | |
import javafx.application.Application; | |
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.layout.StackPane; | |
import javafx.scene.layout.VBox; | |
import javafx.scene.paint.Color; | |
import javafx.stage.Stage; | |
/** | |
* 1. Loo sisse logimise ekraan (ainult visuaal) | |
* 2. Määra üks võimalik kasutaja ja parool (andmebaasi veel ei kasuta) | |
* 3. Ebaõnnestunud katse näitab kasutajale errorit | |
* 4. Õnnestunud katse puhul vaheta pilt uue vastu (kasvõi roheline ring), . | |
*/ | |
public class Harjutus3_logisisse extends Application { | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
VBox vbox = new VBox(); | |
Scene stseen = new Scene(vbox); | |
primaryStage.setScene(stseen); | |
primaryStage.show(); | |
Label kasutajaLabel = new Label("Kasutajanimi"); | |
TextField kasutajaInput = new TextField(); | |
Label parooliLabel = new Label("Parool"); | |
PasswordField parool = new PasswordField(); | |
Button nupp = new Button("Logi sisse"); | |
Label teadeLabel = new Label(); | |
vbox.getChildren().addAll(kasutajaLabel, kasutajaInput, parooliLabel, parool, nupp, teadeLabel); | |
nupp.setOnAction(event -> { | |
String kasutajaSisu = kasutajaInput.getText(); | |
String paroolSisu = parool.getText(); | |
if (kasutajaSisu.equals("Krister") && paroolSisu.equals("salavark")) { | |
System.out.println("Logisid sisse"); | |
} else { | |
teadeLabel.setText("Ei saa sisse!"); | |
teadeLabel.setTextFill(Color.RED); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment