Adding file to jlist, I add to jframe, one jbutton, one jtextview and one jlist, I add file .txt but effectlly to jtextview ex: C:/Windows/file.txt
JList.add(JList, null);
But theres something went wrong
Thank
Adding file to jlist, I add to jframe, one jbutton, one jtextview and one jlist, I add file .txt but effectlly to jtextview ex: C:/Windows/file.txt
JList.add(JList, null);
But theres something went wrong
Thank
Copyright © 2021 Jogjafile Inc.
You need to work with the List Model for your JList. You can't just directly add to a JList like you've done since the JList is so versatile to handle all sorts of Objects. It's a little more complicated than that.
First you want to make sure your JList actually contains a Default List Model:
Now that your sure your JList contains a List Model you can add items to it.
Perhaps create a Method to do the adding for you:
And how you might use it: