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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:29:58+00:00 2026-06-14T17:29:58+00:00

I am loading a JFrame AdminFrame (with add user and addLocation button on it)

  • 0

I am loading a JFrame AdminFrame (with add user and addLocation button on it) when the user click’s addUser button the new JFrame addUser loads and takes user information. When the information is submitted to server it takes some time(because server is web-based) during that time both of my panels got stuck…what i want is to make AdminFrame clickable and use-able so that user can add new user or can add location…
Here is my AdminPanels add button’s template code…not writing original code because original code to is too messy..

public class AdminPanel extends JFrame{
       public AdminPanel(){
           Initalize();//Do Initalize Stuff
       }
       public void addBtnActionPerformed(){
           //load Child Form
       }
}//End of class

Now here is my AddUser Panel’s adduser button Templete code Orignal code to too messay..

public class AddUser extends JFrame{
       public AddUser(){
           Initalize();//Do Initalize Stuff
       }
       public void addUserBtnActionPerformed(){
           /*
              take user's form input values make a http request send to server
              get response...now what i have to do here to make parent form clickable?
           */
       }
}//End of class
  • 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-14T17:30:00+00:00Added an answer on June 14, 2026 at 5:30 pm

    You need to use a SwingWorker to dispatch your heavy/lengthy operations into another Thread, allowing the UI-Thread(EDT) to respond to events.

    Here is a very simple code showing how SwingWorker can be used (connection to a server is here emulated by a bunch of Thread.sleep()):

    import java.awt.BorderLayout;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.List;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JProgressBar;
    import javax.swing.SwingUtilities;
    import javax.swing.SwingWorker;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    
    public class TestJFrame implements ActionListener {
        private JProgressBar progress;
        private JButton startButton;
        private JButton testButton;
        private SwingWorker<Void, Integer> worker;
    
        public void initUI() {
            JFrame frame = new JFrame(TestJFrame.class.getSimpleName());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            progress = new JProgressBar(0, 100);
            startButton = new JButton("Start work");
            testButton = new JButton("Test me while work is in progress");
            startButton.addActionListener(this);
            testButton.addActionListener(this);
            JPanel buttonPanel = new JPanel(new FlowLayout());
            buttonPanel.add(startButton);
            buttonPanel.add(testButton);
            frame.add(buttonPanel, BorderLayout.NORTH);
            frame.add(progress, BorderLayout.SOUTH);
            frame.setSize(600, 400);
            frame.setVisible(true);
        }
    
        private void showTestDialog() {
            if (worker != null) {
                JOptionPane.showMessageDialog(testButton, "You made a test. See how I still respond while heavy job is in progress?");
            } else {
                JOptionPane.showMessageDialog(testButton,
                        "You made a test, but no job is progress. Hit the \"Start work\" button and hit me again after.");
            }
        }
    
        private void startWork() {
            if (worker != null) {
                return;
            }
            startButton.setEnabled(false);
            worker = new SwingWorker<Void, Integer>() {
    
                @Override
                protected Void doInBackground() throws Exception {
                    // Outside EDT, we cannot modify the UI, but we can perform lengthy operations
                    // without blocking the UI
                    for (int i = 0; i < 10; i++) {
                        publish(i * 10);
                        Thread.sleep(1000);
                    }
                    return null;
                }
    
                @Override
                protected void process(List<Integer> chunks) {
                    // Inside EDT, here we can modify the UI
                    super.process(chunks);
                    // We only care about the last one
                    progress.setValue(chunks.get(chunks.size() - 1));
                }
    
                @Override
                protected void done() {
                    // Inside EDT, he we can modify the UI
                    super.done();
                    progress.setValue(100);
                    startButton.setEnabled(true);
                    worker = null;
                }
    
            };
            worker.execute();
        }
    
        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == startButton) {
                startWork();
            } else if (e.getSource() == testButton) {
                showTestDialog();
            }
        }
    
        public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException,
                UnsupportedLookAndFeelException {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    new TestJFrame().initUI();
                }
    
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display a Loading Image in a new JFrame when the
I'm adding a panel into an already shown JFrame on click of button. Now
Error loading script occurs under FireFox 3 if I quickly click different links on
After loading dynamic content to a DIV, I'd like to add a Close option,
I want to be able to set a JFrame's contentpane after a button inside
public void myMethod { MyProgessBarFrame progFrame = new MyProgressBarFrame(); // this is a JFrame
I've made a gui for my program and used UIManager.put(Button.background, new Color(0,0,0)); UIManager.put(JButton.background, new
Loading new content in a HTML page when users reach the bottom is quite
The code below has a bug. Upon loading the JFrame, press tab to focus
How can I do to create a loading jframe without title bar like Eclipse

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.