0

Login.Java

package Login;    
public class Login extends Application{
@Override
public void start(Stage stage)throws Exception{
    Parent root = (Parent) FXMLLoader.load(getClass().getResource("Login.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("Library Management System");
    stage.show();}
public static void main(String[] args){
launch(args);} }  

LoginController.java

package Login;

public class LoginController implements Initializable {
Librarian l1=new Librarian();
@FXML
private JFXTextField username;
@FXML
private JFXPasswordField password;
@FXML
private JFXButton Loginbutton;
@FXML
private JFXButton CancelButton;
@Override
public void initialize(URL url, ResourceBundle rb) {               
}    
@FXML
private void LibrarianLogin(ActionEvent event) throws SQLException {

    if(l1.isLogin(username.getText(),password.getText())){

            Stage stage = (Stage) this.Loginbutton.getScene().getWindow();
            stage.close();
            adminLogin();
}        
}

@FXML
private void handleCancelBtnAction(ActionEvent event) {
}
 public void adminLogin()
{
 try{
     Stage adminstage = new Stage();
     FXMLLoader adminLoader = new FXMLLoader();
     Pane adminroot = (Pane)adminLoader.load(getClass().getResource("/Librarian/admin.fxml").openStream());
     AdminController adminController = (AdminController)adminLoader.getController();
     Scene scene =new Scene(adminroot);
     adminstage.setScene(scene);
     adminstage.setTitle("Admin Dashboard");
     adminstage.show();

 }
 catch (IOException e){
 }
}
} 

The error occurs when ever I press the login button! I don't know what to do!!! When I replace the admin.fxml with an empty fxml the other window appear when I click the login button!! I have no errors at all but these warnings:

Apr 21, 2018 1:38:07 AM javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 9.0.1 by JavaFX 
runtime of version 8.0.161
Apr 21, 2018 1:38:12 AM javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 9.0.1 by JavaFX 
runtime of version 8.0.161
Mohamed Essam
  • 85
  • 1
  • 9
  • https://stackoverflow.com/questions/35210120/javafx-fxml-api-version-warning. In your case, you probaby need SceneBuilder 8. – SedJ601 Apr 21 '18 at 00:45
  • Maybe you'd get an error if you didn't surround the block throwing it with a `try-catch` that simply ignores the exception. BTW: `adminLoader.getController()` always returns `null` since you're using a static method for loading the fxml. – fabian Apr 21 '18 at 07:30
  • @fabian I dont't understand you! when I load an empty fxml it loads fine!! But when I put some textboxs and some labels it doesn't load and doesn't give me an error – Mohamed Essam Apr 21 '18 at 12:45
  • @fabian here is a github link: https://github.com/MoEssam/Library-Management-System – Mohamed Essam Apr 21 '18 at 12:54

0 Answers0