0

我正在使用 JSoup 来提取标签中的元素。这是我使用 .text() 时的结果:

ACCOUNT
0000001
0000002
0000003

NAME
Customer1
Customer2
Customer3

BALANCE
100.00
200.00
550.00

我想将它显示到我使用 JTable 创建的表中。我需要有人指导我用一些示例代码解决这个问题吗?

4

1 回答 1

2
import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class SimpleTable {
    public SimpleTable(){                                                                  
        JFrame f = new JFrame();
        Object[][] tableInputs = {
        { 
            "Customer1","0000001", "100.00",
        },
        { 
            "Customer2", "0000002", "200.00"
        },
        { 
            "Customer3", "0000003", "550.00"
        }};
        String[] header = { "NAME", "ACCOUNT", "BALANCE" };
        JTable table = new JTable(tableInputs, header);
        table.setPreferredScrollableViewportSize(new Dimension(500, 100));
        JScrollPane scrollPane = new JScrollPane(table);
        f.add(scrollPane);
        f.setTitle("Simple Table");
        f.pack();
        f.setVisible(true);
    }
    public static void main(String[] args) {
        SimpleTable b = new SimpleTable();
    }
}
于 2013-06-08T06:29:22.423 回答