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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:34:51+00:00 2026-05-31T19:34:51+00:00

In my application two frame is there. In main frame Server button is there.

  • 0

In my application two frame is there. In main frame “Server” button is there. When I click on “Server” button second frame will open and after enter some detail when i click on “submit” button which is on second frame this frame will close and control again go to the “Server” button where I call this frame so I will do my rest of task.
And one more thing I want in my application when the second frame is open then no activity is on first frame.

My first frame is: JFrame frame;

In this frame one Server button is there: JButton btnSaveOnServer;

In addActionListener of this button I write this code to open second frame:

btnSaveOnServer.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                    ServerClass window = new ServerClass();
                    window.serverFrame.setVisible(true);
            }
        });

Code for the Second Frame:

public class ServerClass{
public JFrame serverFrame;
private JLabel userName;
private JLabel password;
private JTextField textUsername;
private JPasswordField textPassword;
private JButton btnOk;
protected ServerClass(){
try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

        serverFrame = new JFrame("Server Entry Token");

        serverFrame.setBounds(500, 280, 335, 250);
        serverFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        serverFrame.getContentPane().setLayout(null);

        font = new Font("Arial", Font.BOLD, 15);

        userName = new JLabel("Username");
        userName.setBounds(4, 40, 100, 15);
        userName.setFont(font);

        password = new JLabel("PassKey");
        password.setBounds(4, 69, 100, 15);
        password.setFont(font);

        textUsername = new JTextField();
        textUsername.setBounds(110, 35, 200, 25);
        textUsername.setFont(font);


        textPassword = new JPasswordField(10);
        textPassword.setBounds(110, 65, 200, 25);
        textPassword.setEchoChar(ch);

        btnOk = new JButton("Submit");
        btnOk.setBounds(30, 170, 85, 25);

        serverFrame.add(userName);
        serverFrame.add(password);
        serverFrame.add(textUsername);
        serverFrame.add(textPassword);
        serverFrame.add(btnOk);

        btnOk.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (!textUsername.getText().equals("")
                        && !textPassword.getText().equals("")) {

                    tArea.append("Username:\t"+textUsername.getText()+"\n");
                    tArea.append("Pass:\t"+textPassword.getText()+"\n");
//tArea is the area in first frame where I display the entered data.
            serverFrame.dispose();      
                }

            }
        });
}

}

Here I add the code serverFrame.dispose(); in “Submit” button which close the frame but control not come to the first frame.
So my problem is:

  1. How I disable or inactive my first frame while second frame is open.
  2. in my code I am calling second frame in “server” button of first frame. Is this write way to call second frame into first frame?
  3. how I close the second frame (after clicking on submit button) so frame will close and control will go to the “Server” button of first frame.
  • 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-31T19:34:52+00:00Added an answer on May 31, 2026 at 7:34 pm

    1) In my application two frame is there

    don’t use two JFrames, thats isn’t possible without using (JNI or JNA), these containers doesn’t implements parent, there is hard job move one JFrame toFront() / toBack() / real FocusRecycle is cruel joke

    2) use JDialog, with setModal or ModalityType,

    3) plain vanilla JOptionPane is best way ho to do it,

    4) JFrame / JDialog / JWindow doesn’t implements finalize(), then doesn’t matter if you call for setVisible(false) or dispose()

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

Sidebar

Related Questions

I'm working on an ASP.NET web application. There's a bill page which has two
I am working on ajax using struts 2 frame work. Application has two text
I am developing the chatting application but by using that application two persons are
I have two application that need to talk to each other. App1 needs to
My application has two node types: a parent node which can hold recursive child
I have a web application and two class files, First class is MyClass.class which
I have a web application containing two web services, let's say PublicHello.asmx and RestrictedHello.asmx
I'm developing an application on two different machines (home and work) and while the
I'm trying this in two application; a console application and a web application. In
I've got a Windows Forms application with two ListBox controls on the same form.

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.