Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:17:26+00:00 2026-06-04T00:17:26+00:00

I have a Jframe class that has a login and password fields. When loggin

  • 0

I have a Jframe class that has a login and password fields. When loggin on, i have to display informations of the person that logged in, so i have to retrieve his login from the first Jframe to make a treatment in the other one.
Here is that i made, but the login returns NULL in the second jframe:
First Jframe (login and password fields):

private void button_connectActionPerformed(java.awt.event.ActionEvent evt) {                                               
    // TODO add your handling code here:
    String x= loginField.getText();
    String y= passwordField.getText();
    AuthentificationDAO authDAO= new AuthentificationDAO();
    boolean ok_login= authDAO.verify_login(x);
    int pass= Integer.parseInt(y);
    System.out.println("password retrieved"+pass);
    boolean ok_pass=authDAO.verify_password(pass);
    System.out.println("ok pass"+ok_pass);
    if (ok_login & ok_pass)
    {
        System.out.println("Login found!");
        Enseignant e= new Enseignant();
      edu.app.persistence.Enseignant ens= new edu.app.persistence.Enseignant(x);
      //ens.setLogin(x);
        System.out.println("login SET:"+ens.getLogin());
        e.setVisible(true);
        this.setVisible(false);


    }
    else {
        System.out.println("Login NOT found!");
        JOptionPane.showMessageDialog(null, "Accourt NOT found. Please check your login or password.", "Check Login/Pass", 1);
    }

Second Jframe that will display informations of that login:

private void mauvaisFieldFocusGained(java.awt.event.FocusEvent evt) {

edu.app.persistence.Enseignant ens= new edu.app.persistence.Enseignant();
String login=ens.getLogin();
System.out.println("LOGIN EST:"+login);
StatsDAO stats= new StatsDAO();
int id=stats.get_id_from_login(login);
System.out.println("ID="+id);

}

Any idea please of how solving that problem?
Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:17:27+00:00Added an answer on June 4, 2026 at 12:17 am

    Unless ens.login is static, this code won’t work.

    You can use the MVC pattern or you can just make your second frame class extends JFrame, in order to add a login field to it..

    Sonething like :

        class1 {
            class2 frame2 = new class2();
            void login(){
                String x = loginField.getText();
                edu.app.persist.teach ens= new edu.app.persist.teach(x);
                class2.setLogin(x);
            }
       }
    
       class2 extends JFrame{
           String login;
           String getLogin(){..}
           void setLogin(String s){..}
           .
           .
       }
    

    I’ve used a sort of pseudocode but it should be clear enough

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a GUI that inherits from the JFrame class and has its
I have a class that extends JFrame, and it has a BorderLayout. It has
I have this class called PollFrame that extends JFrame in a file called PollFrame.java
I have a main controller class that shows a JFrame containing a JTable and,
I have this code: public class Window extends JFrame { public Window(){ ... JButton
I have this class for my UI public class MyFrame extends JFrame{ JTextArea textArea;
I have the following code: public class Test extends JFrame implements ActionListener{ private static
I have created 2 classes as follows... public class A extends JFrame { public
I have a JPanel that has several (25) JLabel s on it, using a
I have an interface that has multiple small JTables stacked on top of each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.