需要制作一个包含1000行的JTable [英] Need to make a JTable with 1000 rows

查看:71
本文介绍了需要制作一个包含1000行的JTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为客户端开发Java中的GUI应用程序.该GUI的其中一部分需要上传大约1000条记录,每个记录同时具有17个属性(即,它需要1000 X 17表).现在,Netbeans IDE 7.2.1一次在Jtable中最多允许100行.任何建议如何使我一次可以显示1000个条目.我考虑过一个接一个的10个表,但这会在以后的后端留下非常混乱的编码!

I am working on a GUI application in Java for a client. One of the parts of that GUI needs to upload about a 1000 records each having 17 attributes simultaneously(i.e. it needs a 1000 X 17 table). Now Netbeans IDE 7.2.1 allows at most 100 rows at a time in a Jtable. Any suggestions how can i make one for displaying 1000 entries at a time. I considered having 10 tables one after other but that will leave a very messy coding to be done later at the back end!

推荐答案

不要使用IDE来创建GUI. IDE会生成可怕的代码,用您要创建的行数的空值创建一个表.

Don't use an IDE to create your GUI. The IDE generates terrible code that creates a table with the null values for the number of rows that you want to create.

表可以容纳的行数没有限制.如果您手动创建代码,则可以执行以下简单操作:

There is no restriction on the number of rows a table can hold. If you create the code manually you can do something simple like:

DefaultTableModel model = new DefaultTableModel(columnNames, 0);
JTable table = new JTable(model);

这将使用您指定的列名创建一个空表

which will create an empty table with the column names that you specify

然后,您可以使用DefaultTableModel.addRow(...)方法分别添加行.

Then you can add rows individually using the DefaultTableModel.addRow(...) method.

或者您可以使用DefaultTableModel.setDataVector(...)方法一次添加所有行.

Or you can add all the rows at one time by using the DefaultTableModel.setDataVector(...) method.

这篇关于需要制作一个包含1000行的JTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆