【Java-GUI】10 Swing06 JTable
[编程语言教程]

静态数据表格的样子:

package cn.dzz;

import javax.swing.*;
import java.awt.*;

public class JTable {

    JFrame jFrame = new JFrame("简单表格");

    Object[] titleList = {"姓名", "年龄", "性别"};
    Object[][] dataList = {
            {"李清照", 29, "女性"},
            {"苏格拉底", 56, "男性"},
            {"李白", 35, "男性"},
            {"弄玉", 18, "女性"},
            {"虎头", 2, "男性"},
    };

    public void init() {
        javax.swing.JTable jTable = new javax.swing.JTable(dataList, titleList);
        jFrame.add(new JScrollPane(jTable));

        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        jFrame.pack();
        jFrame.setVisible(true);
    }

    public static void main(String[] args) {
        new JTable().init();
    }


}
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » 10 Swing06 JTable