The normal way to display a table from a database is of course a JTable
. But if you want to opt for 2 JList
s instead, it is basically the same principle.
Create a model based on the contents of the database (in this case a ListModel
). You can probably just extend from AbstractListModel
. Once you have your model, it is trivial to create a JList
for it by just passing the model in the constructor.
See the How to use lists tutorial and pay special attention on the Creating a model part of that tutorial
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…