为什么我的jTable的setBounds不起作用

时间:2018-05-18 01:27:33

标签: java swing jtable

我试图使用table.setBound,但我认为它不起作用。

这是代码。

public GUI() {
        this.setSize(800, 400);
        this.setLocationRelativeTo(null);
        this.setResizable(false);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setTitle("GUI");
        JPanel panel = new JPanel();
        this.add(panel);
        String[] col = { "Name", "grade" };
        Object[][] cells = {{ "A", "B" }, { "C", "D" }, { "E", "F" }};
        JTable table = new JTable(cells, col);
        table.setBounds(0, 0, 600, 100);
        panel.add(new JScrollPane(table));
        this.setVisible(true);
}

这是输出

enter image description here

0 个答案:

没有答案
相关问题