Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing GUI Components at Runtime  RSS feed

 
Tyler Robbins
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm making a GUI for the first time. I have to make a program that simulates an elevator system. I'm trying to resize a button to simulate the height that the elevator is currently at during runtime. The button size nor text will update until the loop is done and it returns. Is there any way to update this during runtime? Also, I'm open to other ideas. Thanks in advance.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> The button size nor text will update until the loop is done and it returns.

no crystal balls here - post your (errant) code.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read Concurrency in Swing. I'm 99% sure this is the cause of your problem - your loop is executed on the Event Dispatcher Thread (EDT), and therefore all updates to the GUI will wait until the loop is finished.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!