This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update JScrollPane content (JList)

 
Andres Del Pino
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i´m having a problem doing this, i´ve been searching but didn´t find something useful so i ask you...

I have some JScrollPane and when someone click a button i want to change the contents of the JScrollPane

Here comes some code:


And when i click the button i do this:


But this seems to do nothing, any help? <-- UPDATE
In fact it does something, internally it seems to have changed, but I still see the same info. For example...
I have a JScrollPane and it shows elements 4 5 and 6, when i press the button it should only show 5 but i still see 4, 5 and 6, but when i click any of them it has element 5 info like it has really changed but i need to see only 5 in the JScrollPane
This is an applet, but that doesn´t change anything, right?
Thank you
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a bit of a trouble understanding the code because of the non english names

If you want to update the data in the JList use JList#setListData
If you want to show/hide the JLists (embedded inside the JScrollPane) always invoke JPanel#revalidate and JPanel#repaint after you finish adding/removing

 
Andres Del Pino
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry the code was in spanish, I translated it so you can understand it better.

I solved it, the problem was the JPanel#revalidate, i wasn´t doing it, so, thank you Maneesh.

I´ll post the final code for people with the same problem:



Thanks for the help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic