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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:49:08+00:00 2026-06-15T14:49:08+00:00

I ma new in OOD and working on Academic project. I am facing a

  • 0

I ma new in OOD and working on Academic project.
I am facing a problem while programming it.

The scenario is that I have a main class in which I have made an object of “login” class and call its function.

Now in that “login” class function I create an object of jFrame class to show a login view, where user enters the login info and press login button.

Now I want that when user press login button I should pass that info to an authenticate function in my “login” class.

The problem is that how can I call that function (its a non-static function), and upon invalid info call a function of jFrame class to show error message.

And I want to do this function calling all over in my project.

  • 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-15T14:49:09+00:00Added an answer on June 15, 2026 at 2:49 pm

    Maybe you need to redesign your program a bit. The login class should not be creating a JFrame. Let the login class concentrate on authenticating users and its related functions. So something like this:

      public class Login{
    
          public boolean authenticate(String uname, String pword){
               return .......
          }
    
      }
    

    Whenever you need to use the functions of Login, you can instantiate it and call the function. You can create a JFrame for instance that prompts the user for username and password and in the action of the button:

             loginBtn.addActionListener(new ActionListener(){
                    public void actionPerformed(ActionEvent e){
    
                          Login login = new Login();
                          if(login.authenticate(txtUname.getText(), txtPWord.getText())){
                                  //display success on JFrame
                          }else{
                                  //display failure on JFrame
                          }
                    }
              });
    

    Where txtUname and txtPWord may be 2 JTextFields on you JFrame, and lginBtn may be a button on your JFrame.

    If you need to perform the same function somewhere else then you instantiate Login again and call the function.

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

Sidebar

Related Questions

I'm new to OOD so I have a question about the use of classes
(New to Objective-C, but well versed in C/C++). Presently I have an Objective-C class
(New to ASP.NET here.) I have a user control which should check for a
New view based project in XCode Go to main.xib and view.xib respectively In each
New to XML. I have a 3rd party webservice that supplies an XML document
I'm relatively new to OOD, C#, WPF, but trying to learn. So I have
New to programming and need a little assistance. I have a WPF usercontrol used
New to cpp (Java guy). I have 3rd party library that has method sendMail(txt).
New to iPhone app development, I have a problem compiling (or Build and Run)
I have an OOD system for my current webApp that every element has an

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.