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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:05:54+00:00 2026-06-16T01:05:54+00:00

I have two basic questions. I have a GUI project with Java Swing. When

  • 0

I have two basic questions.

  • I have a GUI project with Java Swing. When I put buttons on the frame and I double clicked them, I had the code of the actionPerformed, but it is blocked.

    How can I put there a button and then use it on a actionListener?

  • My Project is about Server-client (multithread and sockets)

    I call one method to reiceve one string that we can write on a JtextField and it stays on a while cicle with PrintWriter and a getOutputStream.

    Something like:


do{
...
}while(thisstring!=null || thisstring!="exit")

So.. when I write something and press the button to send it, it stays on the cicle and the button blocks. How can I unblock the button to write something else?

Edit:
I understood the EDT problem, but I can’t solve it.

I tried use the Timer but without success, something like that:

  int delay = 1000; //milliseconds
  ActionListener listener = new ActionListener() {
  public void actionPerformed(ActionEvent e) {
  //My action calling the Thread class with the while cicle that has the PrintWriter
       }

  };
new Timer(delay, listener).start();

How can I handle this to do the timer when I press the button?

How can I stay on the that cicle (read the comment line) to send the information by OutputStream every time that one user enter something on the text field?
I know that for example for a console application I use a BufferedReader and then I use the ReadLine() to wait for anything sent from the console, but with GUI interface it freezes all time..

  • 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-16T01:05:56+00:00Added an answer on June 16, 2026 at 1:05 am

    There is a fundamental concept in Java GUI development surrounding which thread in which the developer implements user-interaction processing such as button clicks.

    In short, you need to perform your processing outside of the thread that calls your action handling method. This single thread is known as the Event Dispatch Thread (EDT), and if you have logic that runs much more than a few milliseconds, it will prevent the UI from continuing to draw things like the button releasing, etc.

    You’ll want to move your long-running, socket code off the EDT. Doing so will allow the button to release and let the user interact with other controls (or even the same button).

    To avoid duplicating other discussions on the topic, I direct you to this pretty good one. Additionally, this article gives a short overview of threading concepts in Swing.

    Regards,

    ScottH

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

Sidebar

Related Questions

I have a very basic app with two ignition-remoteimageviews (RIV) in them. The app
I have two basic questions. The first one is about function in other classes.
Im newbee in mongoid and I have two basic (I think) questions. Whats best
I'm new to C++, so this question may be basic: I have two classes
I have two basic interface-related concepts that I need to have a better understanding
I have two projects: a profiler and a basic application (with JUnit tests) The
I have a basic.xsd and two other A.xsd and B.xsd . A.xsd and B.xsd
I have a basic program that compares two strings : #include <string> #include <iostream>
I have a very basic page with two elements, an outer green box, and
I have just a basic html form within index.php which contains two text fields:

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.