• Post Reply Bookmark Topic Watch Topic
  • New Topic

While loop infinity error maybe?  RSS feed

 
James obrien
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator






I need some help please. I know I need a while loop because I need a constant loop. I am trying to edit a jlist the gui disappears (turns grey).I thought it might be an issue with updating the gui.Any hints would be nice. p.s I had though of an idea of calling an action listener repeatedly through a while loop. I don't think it is possible though as I can't find an example.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I can’t help with the bit about greyed‑out GUIs because you haven’t told us enough details.
There is something wrong. How are you selecting the index? It looks as if you are selecting index i and continuing for ever, because there doesn’t seem to be any way to change that index. The loop will continue until list cannot be focussed.
By the way: I don’t like break; and it is completely unnecessary where you have it. Never use == true and == false.Use spaces, not tabs, for indenting.
 
James obrien
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Thank you for your help. The index was not doing what I though it should.I was trying to do some sort of polling, which I guess is what action listener is for. I am always confused how while loops work. I went back to trying to implement an action listener. This code works. p.s the code tags seem to be a lil skeewiff. I am using a chrome browser mac OSX mountain lion.
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James obrien wrote:I was trying to do some sort of polling, which I guess is what action listener is for.

<off-topic>
Actually, it isn't - and in general, you don't need polling between objects (ie, an object that "checks status" periodically). The "listened to" object (eg, a Button) simply 'tells' the Listener when (and only when) something happens; there is no "polling" involved.
</off-topic>

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!