有没有办法读取 JScrollPane 的内容?
我已经实现的是使用该方法添加DefaultTableModel
的。我将其用作声明和实现 a 的参数。这稍后用作 a 的声明和实现的参数。在代码的整个执行过程中,我在using方法中添加了 nows。我手头的目标是阅读添加的行的内容。three columns
addColumn()
DefaultTableModel
JTable
JTable
JScrollPane
DefaultTableModel
addRow()
有没有人有什么建议?一切将不胜感激!
JTabbedPane tabbedPane = new JTabbedPane();
DefaultTableModel model = new DefaultTableModel();
model.addColumn("Column1");
model.addColumn("Column2");
model.addColumn("Column3");
JTable testResults = new JTable(model) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
JScrollPane resultTab = new JScrollPane(testResults);
resultTab.setName("Tab1");
resultTab.setVisible(true);
Thread thread1 = new Thread() {
public void run() {
if(tabbedPane.getSelectedComponent().getName().compareTo("Tab1") == 0) {
model.addRow(new Object[]{"content1", "content2", "content3"});
model.addRow(new Object[]{"content4", "content5", "content6"});
...
...
...
model.addRow(new Object[]{"this", "will", "continue"});
}
else {
model.addRow(new Object[]{"content1", "content2", "content3"});
model.addRow(new Object[]{"content4", "content5", "content6"});
}
};
thread1.start();
I want to read the data "content1", "content2", "content3", "content4", "content5", "content6", etc. The ellipses represent that there is a undefined number of rows being added throughout the source code.