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

  • Home
  • SEARCH
  • 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 9187199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:42:37+00:00 2026-06-17T19:42:37+00:00

What is a secure way to store login information? I have a swing application

  • 0

What is a secure way to store login information? I have a swing application that requires users to login to an online account, currently logging in works, but I would like to be able to store the users login information on their computer if possible. There are a few ways I have thought of to do this:

  1. Save the login information in a file
  2. Save the login information in a database

What is the best way to do this? Does Java have something built in to do this?

  • 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-17T19:42:38+00:00Added an answer on June 17, 2026 at 7:42 pm

    I decided to use the Preferences API, to store and retrieve data
    http://docs.oracle.com/javase/7/docs/api/java/util/prefs/Preferences.html

    Here is a rough example of the final code:

    public class Login extends javax.swing.JDialog{
        // Get saved info and set the textbox text
        public Login(){
            String userName = pref.get("user", "");
            if(!userName.equals("")){
                this.user.setText(userName);
            }
            String passName = pref.get("pass", "");
            if(!passName.equals("")){
                this.pass.setText(passName);
            }
        }
    
        // Run on login button click
        public void login(){
            String p = new String(pass.getPassword());
            DoLogin log = new DoLogin(user.getText(), p);
            log.execute();
        }
    
        // Process in background
        public class DoLogin extends SwingWorker{
            public void done(){
                // On successfull login save user data
                pref.put("user", this.strUser);
                pref.put("pass", this.strPass);
            }
    
            public String doInBackground(){
                // Process login
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like most users, I'm simply trying to figure out a secure way to store
I'm wanting a more secure way to store high scores and power ups like
I'm using the has_secure_password way to store a secure password in the database. When
I have some Ruby web apps that use OpenID for authentication and store the
I'm trying to write a javascript single-page-app that allows users to login and then,
What is the best way to store username and SHA1 login for an intranet
My application requires the user to login on their first visit, and then it
My application requires the user to login on their first visit, and then it
I am working on a central login system for an application that is written
Possible Duplicate: Best way to store password in database I have a database (mySQL)

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.