Populating a JList with Data

Does anyone have any good tutorials on how to populate a JList (inside JPanel ) with user input. In particular, I want to add people to the selected list. Is it a matter of filling it with an ArrayList ?

Any help would be greatly appreciated.

+4
source share
4 answers
  • create a ListModel that wraps your java.util.List (e.g. extending AbstractListModel)
  • configure jlist to use this model
  • create and configure a visualizer to format / display objects in your list as needed

http://docs.oracle.com/javase/tutorial/uiswing/components/list.html

+6
source

You create a JList with ListModel . When you edit your ListModel , this is reflected in the JList .

+3
source

I think he has some time with Google. I found the following results on Google.

+3
source

Use any layout manager, such as Gridlayout .

0
source

Source: https://habr.com/ru/post/1384931/


All Articles