JTable与自定义TableModel [英] JTable vs. custom TableModel
问题描述
我正在尝试在Java GUI上实现JTable,该JTable可以用文件中的值填充自身,并允许用户对各种单元格进行修改.由于我在Netbeans IDE中使用GUI编辑器,因此我的第一个直觉是将JTable从面板添加到表单中.但是,我很快意识到我不能向表中添加超过100行(对于我的应用程序,我需要大约500多个行).另外,在寻找解决方案时,我注意到很多人说使用Custom TableModel代替JTable是因为它更健壮/高效.
I am trying to implement a JTable on a Java GUI that can fill itself with values from a file and allow the user to make modifications to various cells. Since I'm using the GUI editor in the Netbeans IDE, my first instinct was to add the JTable to my form from the palette. however, I quickly realized that I couldn't add more than 100 rows to the table (for my application i'd need around 500+). additionally, while searching for a solution to this problem, I noticed a lot of people saying to use a Custom TableModel instead of using the JTable because it is more robust/efficient.
首先,有没有一种方法可以向JTable中添加100多个行?其次,使用JTable(使用DefaultTableModel)真的是一个不好的实现吗?我的表单非常复杂,所以我宁愿使用GUI编辑器来调整JTable的大小,位置等,而不是对其进行硬编码.
first, is there a way to add more than 100 rows to a JTable? secondly, is using the JTable (which uses the DefaultTableModel) really a bad implementation? my form is pretty complex, so I would prefer to use the GUI editor to adjust the size, position, etc. of my JTable as opposed to hard-coding it.
推荐答案
是否可以向JTable添加100行以上?
is there a way to add more than 100 rows to a JTable?
为什么限制为100?这听起来像您的IDE,而不是DefaultTableModel.数以万计的行对于DefaultTableModel来说是没有问题的(不是任何用户都希望查看所有数据).
Why is 100 a limit? That sounds like your IDE, not the DefaultTableModel. Tens of thousands of rows is no problem for the DefaultTableModel (not that any user would want to look at all that data).
这篇关于JTable与自定义TableModel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!