如何在我的 jtable 中获取超过 100 行?
how to get more than 100 rows in my jtable?
如何让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) {
}
我想制作一个 "next" 按钮来查看文件中的下 100 个数据
看下限额“我有400多条显示只有100条
这些是我用过的进口商品
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
请像我是个傻瓜一样解释 java
在 DefaultTableModel
中添加您的数据,然后将其设置为 JTable
的模型。
我不确定这是否是您的意思,但您可以创建一个变量来保存页码。
int page = 1;
for (int r = 0; r < 100 * page; r++) { //initializing row
for (int c = 0; c < 4; c++) { //initializing column
jTable1.setValueAt(null, r, c);
}
}
通过按下按钮,您可以递增或递减页面,以便页面呈现下一页。
如何让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) {
}
我想制作一个 "next" 按钮来查看文件中的下 100 个数据
看下限额“我有400多条显示只有100条
这些是我用过的进口商品
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
请像我是个傻瓜一样解释 java
在 DefaultTableModel
中添加您的数据,然后将其设置为 JTable
的模型。
我不确定这是否是您的意思,但您可以创建一个变量来保存页码。
int page = 1;
for (int r = 0; r < 100 * page; r++) { //initializing row
for (int c = 0; c < 4; c++) { //initializing column
jTable1.setValueAt(null, r, c);
}
}
通过按下按钮,您可以递增或递减页面,以便页面呈现下一页。