【发布时间】:2017-06-11 20:51:12
【问题描述】:
大家好,我想寻求一些帮助,我不明白我的代码在打开表格后的错误在哪里,只显示一个玩家
/**
* Create the frame.
*/
public Player()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 316, 475);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
// create table with data
// headers for the table
column = new String[]
{
"Id",
"Name",
"level",
"Part Time"
};
for (L2PcInstance pc : L2World.getInstance().getPlayers())
{
if (pc.isOnline() && ((pc.getClient() != null) && !pc.getClient().isDetached()))
{
// actual data for the table in a 2d array
data = new Object[][]
{
{
pc.getId(),
pc.getName(),
pc.getLevel(),
false
},
};
}
}
// create table with data
JTable table = new JTable(data, column);
contentPane.add(table, BorderLayout.NORTH);
}
}
感谢大家的宝贵时间 :) 抱歉英语不好
【问题讨论】:
-
如需尽快获得更好的帮助,请发帖minimal reproducible example 或Short, Self Contained, Correct Example。
-
请包含您的其余代码实例化和使用它,以便其他人可以帮助调试。
标签: java swing for-loop jtable