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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:51:17+00:00 2026-06-10T11:51:17+00:00

SO i am working on a project and i was trying to disable the

  • 0

SO i am working on a project and i was trying to disable the frame and the field from the program so that only the window is front is this one being active
here is my code :

 import javax.swing.*;
 import java.awt.event.*;
 import java.awt.*;

public class password
{
  private static String password = "pass";
  public static void main(String[]args) {
    JFrame frame = new JFrame("Password");
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400,100);
    JLabel label = new JLabel("Enter password");
    JPanel panel = new JPanel();
    frame.add(panel);
    JPasswordField pass = new JPasswordField(10);
    pass.setEchoChar('*');
    pass.addActionListener(new AL());
    panel.add(label, BorderLayout.WEST);
    panel.add(pass, BorderLayout.WEST);
}
static class AL implements ActionListener
{
    public void actionPerformed(ActionEvent e) {
        JPasswordField input = (JPasswordField) e.getSource();
        char [] passy = input.getPassword();
        String p = new String(passy);
        if (p.equals(password)){
            JOptionPane.showMessageDialog(null, "Correct");
            System.out.print("Welcome to Adam's Quirky program.");



        }
        else
            JOptionPane.showMessageDialog(null, "Incorrect");
       }
    }
 }

the program i am currently using to program is Eclipse.

  • 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-10T11:51:18+00:00Added an answer on June 10, 2026 at 11:51 am

    I’d take a look at a modal dialog.

    Either use a JOptionPane or roll your own.

    If these don’t suit your needs, try taking a look at JLayer (Java 7) or JXLayer (Java 6 and below)

    Have a look at LockableUI (It’s a little out of date, but the basic idea is the same)

    If that doesn’t appeal, you could use a “blocking glass pane”

    Take a look at

    • glassPane is not blocking input
    • Is there a problem with this blocking GlassPane?

    as some examples

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

Sidebar

Related Questions

I'm not currently working on a coding project that is trying to implement this,
I have a working project that Im amending, it crashes after trying to use
I'm working on a project that is trying to use context-free grammars for parsing
I'm trying to get MSBuild working on a project that has just been moved
I'm working on a project that's trying to implement some editing features using a
Trying to run gvim 7.3 from the working directory (project location) seems impossible-- it
I am trying to get a web application project working, after we moved from
I am working on this project in which I am trying to get a
I'm currently working on a project trying to update a page reading from an
I am working on this project just trying to keep up my c++ knowledge.

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.