Results 1 to 3 of 3
  1. #1
    simplo is offline Member
    Join Date
    Aug 2010
    Posts
    14
    Rep Power
    0

    Default Gui Blocked after selected a Jcheckbox

    Hi guys ,
    i wrote a progamm to print msesage while the Jchekbox is selected , but the problem is : my gui completely blocked when i check my box (also my jCheckBox is no more selectable). can someone tell me how to resolve the problem ? . here is my code : The red marked code block the gui ( i think)

    private void jCheckBox1ItemStateChanged(java.awt.event.ItemEven t evt) {

    boolean state = jCheckBox1.isSelected();
    if(state ){
    try {
    send("start tick");
    } catch (IOException ex) {
    Logger.getLogger(DiagClient.class.getName()).log(L evel.SEVERE, null, ex);
    }
    try {
    do{
    socket.receive(buffer);

    recvMsg = new String (inData ,0 ,buffer.getLength());
    System.out.println(recvMsg);
    }
    while(buffer.getLength() !=0);

    } catch (IOException ex) {
    Logger.getLogger(DiagClient.class.getName()).log(L evel.SEVERE, null, ex);
    }


    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    You're blocking the EDT, the main thread used by Swing to do user interaction and painting. Best to do your long-running process in a background thread such as a SwingWorker. Check out the Sun/Oracle tutorial on this for more information: Concurrency in Swing

  3. #3
    simplo is offline Member
    Join Date
    Aug 2010
    Posts
    14
    Rep Power
    0

    Default

    thanks , i solve the problem using SwingWorker , now i have the same Problem with Applets:
    when i run my applet in Netbeans all is ok the button doens´t block, but when i insert this applet in a Browser , the checkbutton block .
    any idea ?

Similar Threads

  1. How to add a jcheckbox in jtable
    By lakshayghai in forum AWT / Swing
    Replies: 9
    Last Post: 04-14-2010, 11:32 PM
  2. Replies: 2
    Last Post: 03-19-2010, 08:24 AM
  3. How can I add JCheckBox to each row?
    By batya in forum AWT / Swing
    Replies: 1
    Last Post: 11-04-2009, 09:25 PM
  4. JCheckbox in Jtree
    By shajuantony in forum AWT / Swing
    Replies: 10
    Last Post: 09-09-2009, 10:42 AM
  5. blocked between server and clients
    By ibtehal in forum Networking
    Replies: 6
    Last Post: 07-17-2008, 12:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •