This is the login logic of the login pane, when user input their username and password, if both are 1, then they will enter the main pane and the label at the right top in the main pane will show their username.
login_btn.setOnAction(event -> {
String input_name = username.getText();
String input_pw = password.getText();
String true_name = "1";
String true_pw = "1";
System.out.println("username: " + input_name);
System.out.println("password: "+ input_pw);
log_condition = input_name.equals(true_name) && input_pw.equals(true_pw);
System.out.println("login condition: " + log_condition);
if (log_condition) {
try {
user = input_name;
System.out.println("user: " + user);
Main.stage.close();
main_pane();
} catch (IOException e) {
e.printStackTrace();
}
}
This code is how to set the username in the label but it does not work. the Label id will show nothing after the user enters this pane. The loginPanel_ui is the code above.
public class mainPane_ui implements Initializable {
@FXML
public static Button newer;
@FXML
public static Button recommend;
@FXML
public static Label id = new Label();
@Override
public void initialize(URL location, ResourceBundle resources) {
id.setText(loginPanel_ui.user);
id.setTextFill(Color.WHITE);
}