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 7047001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:43:04+00:00 2026-05-28T02:43:04+00:00

Im using swing in java to make a quiz for my coursework. I have

  • 0

Im using swing in java to make a quiz for my coursework. I have made my main class, a tabbed frame that holds separate jpanels as tabs for example the login page, and im using sqlite to get my data. However Im struggling to see how i can communicate between say my login jpanel and my main class.

mainJFrame.addWindowListener(new WindowAdapter() {
        public void windowActivated(WindowEvent arg0) {
            LoginPanel loginEntry = new LoginPanel();
            welcomePanel.add(loginEntry);
            welcomePanel.setBounds(0,0,728,390);

//So here i would like an if statement so that on successful login, the other tabs are added and can be seen. But are not available if you are not logged in.

                tabbedPane.addTab("Quick Guide", null, quickGuidePanel, null);
                tabbedPane.addTab("Examples", null, examplePanel, null);
                tabbedPane.addTab("Run Quiz", null, runQuizPanel, null);
                tabbedPane.addTab("Exams", null, examPanel, null);
                tabbedPane.addTab("View Performance", null, viewPerfPanel, null);
                tabbedPane.addTab("Settings", null, settingsPanel, null);

        }
    });

I tried creating a getter and setter and tried to getSuccessfulLogin() but that wasn’t working 🙁

thanks

  • 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-05-28T02:43:05+00:00Added an answer on May 28, 2026 at 2:43 am

    I good way to populate your loginInformation in the Application would be a Singleton Pattern.
    For example:

    public class AuthService {
       private static AuthService myInstance;
    
       private User currentUser;
       ...
    
       private AuthService() {
           // Constructor is private. The Object can only be instanciated by getInstance()
       }
    
       public static AuthService getInstance() {
          if (myInstance == null) {
             myInstance = new AuthService();
          }
    
          return myInstance;
       }
    
       public User getCurrentUser()
       ...
    
    
       public void setLoggedInUser(User user)
       ...
    
       public User login(String userName, String password)
       ...
    
    }
    

    Via the static getInstance()-method you can get an Instance of exact the same object everywhere in your Appliaction without the need to carry the Object trough all constructros or methods.
    You can hold all your authentification-related Data there and even some Methods, that do the login-work.
    The getCurrentUser() could return null if no succelsful logged in user exists.

    If it is possible to login from more then one client at the same time you will need to hold different UserInformations for different sessions in your AuthService.

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

Sidebar

Related Questions

im using java swing for my coursework to make a quiz. Below is my
I have made a Java Swing application. Now I would like to make it
i have made a urdu editor using swing in java and now wana add
I am trying to make a Text Editor using Java Swing. In that I
I am trying to create a gui using swing. I have a main frame
I have a java swing App that connects to a remote Unix box using
I am trying to make an animated clock using Swing in Java. The picture
I created a form using Swing in Java. In the form I have used
I am writing an application in java (1.6) using swing. I currently have a
I have designed a GUI connect to DB button using Swing in java now

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.