java - How can i make the JLabel change through different threads without a final String? -
i know seems question asked , answered time , again, after combing through stack overflow hours couldn't solve problem. sorry in advance if i'm missing obvious.
i need change jlable's text each time thread starts, , again when thread finishes. simply, i'm trying show number of threads running.
jobqueueview
static , final jlabel. main
jframe has jlabel. jobqueue
static int.
at start of each thread:
jobqueue += 1; refreshqueue();
at end of each thread:
jobqueue -= 1;refreshqueue();
and finally
public void refreshqueue() { eventqueue.invokelater(new runnable() { @override public void run() { new main().jobqueueview.settext(integer.tostring(jobqueue)); } }); }
this doesn't work. ideas? thanks
edit : per instructions of andrew thompson swing jlabel text change on running application : on button click event
can change text of label thread in java? : has make string final. cant.
update jlabel thread : uses timers, need thread count
jlabel on jpanel doesn't update when settext method : tried given solutions. didn't work
thread , jlabel in swing- not working properly : more button clicks different solutions. still didnt work
it seems creating new frame every time.
new main().jobqueueview.settext(integer.tostring(jobqueuecount ));
so have multiple frames 1 static label. may cause problem. access jobqueueview through static way below.
main.jobqueueview.settext(integer.tostring(jobqueuecount ));
Comments
Post a Comment