How to use threads for this scenario???????

Discussion in 'Java' started by steve smith, Jul 17, 2003.

  1. steve smith

    steve smith Guest

    Hi here is the problem I have I have a panel consisting of radio
    buttons, the buttons are disabled. Each button is associated with a
    value, and when the counter hits that value the button should be
    enabled. The counter is incremented by the user by means of a jButton.
    I tried implementing this by having a while loop which continously
    checked for the counter reaching any of the values of the radio
    buttons so that they could become enabled, only when i ran the program
    it would completely crash. I think the best option would be to use
    threads to do this but I have never used threads before and so would
    like some help on how I should go about this problem? Thanks.
     
    steve smith, Jul 17, 2003
    #1
    1. Advertising

  2. On 17 Jul 2003 11:11:57 -0700, steve smith <>
    wrote:

    > Hi here is the problem I have I have a panel consisting of radio
    > buttons, the buttons are disabled. Each button is associated with a
    > value, and when the counter hits that value the button should be
    > enabled. The counter is incremented by the user by means of a jButton.
    > I tried implementing this by having a while loop which continously
    > checked for the counter reaching any of the values of the radio
    > buttons so that they could become enabled, only when i ran the program
    > it would completely crash. I think the best option would be to use
    > threads to do this but I have never used threads before and so would
    > like some help on how I should go about this problem? Thanks.
    >


    Threads sounds like overkill for this case. It seems more straightforward
    to me to just program it to enable the button when the appropriate value is
    reached.

    --Marc
     
    Marc Rochkind, Jul 17, 2003
    #2
    1. Advertising

  3. On [GMT+1=CET],
    Thomas G. Marshall <>
    horrified us with:

    ....[self snipping]...

    > General Warning: Be very careful of when you call /any/ swing mutator
    > method, since swing is /not/ thread safe in general with very few
    > exceptions. Outside of event handler threads you usually must modify
    > JComponents by setting the modification for later execustion in the
    > event handler thread by calling
    >
    > SwingUtilities.invokeLater();



    Note that this was just a general warning.

    I should have been exceeding precise here: The JButton listener that I was
    talking about /will/ run in the event thread. Within that thread you can
    access all swing mutators safely.
     
    Thomas G. Marshall, Jul 18, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zeng
    Replies:
    5
    Views:
    409
    John Saunders
    Aug 20, 2003
  2. REB
    Replies:
    0
    Views:
    346
  3. Ing. Rajesh Kumar

    How to use validation controls in this scenario ?

    Ing. Rajesh Kumar, Jul 22, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    399
    Sergey Poberezovskiy
    Jul 23, 2004
  4. dan
    Replies:
    1
    Views:
    375
    bruce barker
    Dec 13, 2004
  5. Angus
    Replies:
    11
    Views:
    509
    James Kanze
    Sep 19, 2007
Loading...

Share This Page