【发布时间】:2016-01-19 03:59:54
【问题描述】:
您好,我的问题是以下我有一个特定类的列表,我想将其中的值绑定到 jtable(现在添加它们的顺序并不重要) 列表中的类如下
public HighScore(int score, int amountofplayers, String playerName,String dateString) {
this.score = score;
this.amountofplayers = amountofplayers;
this.playerName = playerName;
this.dateString = dateString;
}
返回列表的函数是
public ArrayList<HighScore> GetHighScores()
{
ArrayList<HighScore> highscores = new ArrayList<HighScore>();
//get highscores from databse
//insert some test values
highscores.add(new HighScore(125, 2, "Piet","20-10-2015"));
highscores.add(new HighScore(167, 2, "Henk", "19-10-2015"));
highscores.add(new HighScore(278, 2, "Jan", "11-10-2015"));
return highscores;
}
所以现在我想将所有这些高分添加到我的 Jtable1 中,该 Jtable1 位于 jpannel 中。最简单/最有效的方法是什么
【问题讨论】:
标签: java swing arraylist jtable