0% found this document useful (0 votes)
53 views4 pages

Admin Tools Controller

This document defines an AdminToolsController class that handles user authentication and navigation between login and admin screens. It contains fields for user/password text fields and login/logout buttons. The login() method authenticates credentials and loads the admin screen interface. The initialize() method sets up keypress handling to trigger login on enter key.

Uploaded by

Angelo Cordero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views4 pages

Admin Tools Controller

This document defines an AdminToolsController class that handles user authentication and navigation between login and admin screens. It contains fields for user/password text fields and login/logout buttons. The login() method authenticates credentials and loads the admin screen interface. The initialize() method sets up keypress handling to trigger login on enter key.

Uploaded by

Angelo Cordero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 4

package GUI;

import com.jfoenix.controls.JFXButton;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;

public class AdminToolsController {

@FXML
public TextField txtUser;

@FXML
public TextField txtPassword;

@FXML
public JFXButton btnLogin;
@FXML
public AnchorPane anchorAfter;
@FXML
private BorderPane brdrAfter;

GraphicalDataController control = new GraphicalDataController();


public void login() throws IOException {
if ((txtUser.getText().contentEquals("Admin")) &&
(txtPassword.getText().contentEquals("Admin"))){
AnchorPane anchor =
FXMLLoader.load(getClass().getResource("AfterLogin.fxml"));
anchorAfter.getChildren().clear();
anchorAfter.getChildren().add(anchor);
}
}

public void logout() throws IOException {


AnchorPane anchor =
FXMLLoader.load(getClass().getResource("AdminTools.fxml"));
anchorAfter.getChildren().clear();
anchorAfter.getChildren().add(anchor);
}

public void clear(){


txtPassword.setText("");
txtUser.setText("");

public void initialize(URL location, ResourceBundle resources) {


txtPassword.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if(event.getCode().equals(KeyCode.ENTER)){
if ((txtUser.getText().contentEquals("Admin")) &&
(txtPassword.getText().contentEquals("Admin"))){
try {
AnchorPane anchor =
FXMLLoader.load(getClass().getResource("AfterLogin.fxml"));
anchorAfter.getChildren().removeAll();
anchorAfter.getChildren().add(anchor);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
});
}
}

package GUI;

import com.jfoenix.controls.JFXButton;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Button;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.AnchorPane;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;

public class AdminToolsController {


@FXML
public TextField txtUser;

@FXML
public TextField txtPassword;

@FXML
public JFXButton btnLogin;
@FXML
public AnchorPane anchorAfter;
@FXML
private BorderPane brdrAfter;

GraphicalDataController control = new GraphicalDataController();


public void login() throws IOException {
if ((txtUser.getText().contentEquals("Admin")) &&
(txtPassword.getText().contentEquals("Admin"))){
AnchorPane anchor =
FXMLLoader.load(getClass().getResource("AfterLogin.fxml"));
anchorAfter.getChildren().clear();
anchorAfter.getChildren().add(anchor);
}
}

public void logout() throws IOException {


AnchorPane anchor =
FXMLLoader.load(getClass().getResource("AdminTools.fxml"));
anchorAfter.getChildren().clear();
anchorAfter.getChildren().add(anchor);

public void clear(){


txtPassword.setText("");
txtUser.setText("");

public void initialize(URL location, ResourceBundle resources) {


txtPassword.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if(event.getCode().equals(KeyCode.ENTER)){
if ((txtUser.getText().contentEquals("Admin")) &&
(txtPassword.getText().contentEquals("Admin"))){
try {
AnchorPane anchor =
FXMLLoader.load(getClass().getResource("AfterLogin.fxml"));
anchorAfter.getChildren().removeAll();
anchorAfter.getChildren().add(anchor);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
});
}
}

You might also like