java gui列表,Java GUI应用程序,将数据从列表<objects>加载到Jtable。

Java GUI aplication, load data to Jtable from a list

i have found the following link but i haven't found an answer: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html

please can someone gice me an example how should i do it.

my objects have 5 fields:Name,Grade,Salary,BirthYear,Sex

and the list is readed from a file so i dont know how many ojects will the List have.

I am working in netbeans.

解决方案

The tutorial you linked to has an example: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#data. You should be able to adapt it to a List easily:

public int getRowCount() {

return list.size();

}

public int getColumnCount() {

return 5;

}

public Object getValueAt(int row, int col) {

Employee employee = list.get(row);

if (col == 0) {

return e.getName();

}

else if (col == 1) {

return e.getGrade();

}

...

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值