java如何在我的jtable中获得100多行?
如何使Jtable读取超过100行?
我需要知道如何为我的Jtable创建下一个和上一个按钮,以便从文本文件中获取数据。
我编写的代码只能读取文件中的前100行。
我用来刷新Jtable的按钮的代码是
try {
for (int r = 0; r < 100; r++) { //initializing row
for (int c = 0; c < 4; c++) { //initializing column
jTable1.setValueAt(null, r, c);
}
}
BufferedReader rdfile = new BufferedReader(new FileReader("items.txt"));
String[] item = new String[100];
String[] temp;
int x = 0; //read item
while ((item[x] = rdfile.readLine()) != null) {
temp = item[x].split("\t");
jTable1.setValueAt((1000 + x + 1), x, 0);
for (int j = 1; j < 4; j++) {
jTable1.setValueAt(temp[j - 1], x, j);
}
x++;
}
rdfile.close();
} catch (IOException e) {
}
看看限制“我有400多件物品,但它只显示100件
这些是我用过的进口货
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
请解释一下,就好像我是java中的傻瓜一样
# 1 楼答案
在
DefaultTableModel
中添加数据,然后将其设置为JTable
的模型# 2 楼答案
我不确定这是否是您的意思,但您可以创建一个保存页面编号的变量
通过按下按钮,可以增加或减少页面,使页面呈现下一页