Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Updating a JLabel on a JPanel  RSS feed

Dane Com
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am in need of assistance with regards as to how to update a JLabel on a JPanel - when an array is updated.

My main program passes in an arrayList to another JFrame program ( and I am able to confirm that the data in the arrayList has been passed into the program ). However, the jLabels are not being updated on the GUI when the program is ran. However, when I use the MOUSE to click on a section of the map I am able to update the map utilizing the mouse clicked and listener and I am then displaying the data from the arrayList.

I am using the same method (see below) to populate the labels so I know it works.

I know I need to employ an action listener to have the labels updated, but I have scoured the web to look for an example that utilizes a listener to update a JLabel and I have not been able to find one.

If anyone could offer assistance it would be greatly appreciated.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!