Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Swing JTable没有显示任何内容_Java_Swing_Jtable - Fatal编程技术网

Java Swing JTable没有显示任何内容

Java Swing JTable没有显示任何内容,java,swing,jtable,Java,Swing,Jtable,我在我的JPanel中添加了Jtable,这是一个简单的代码,但屏幕上什么也没显示。帮助。以下是我的代码: public class AddProduct extends JFrame { private JPanel contentPane; Connection con; private JTable table; /** * Launch the application. */ public static void main(

我在我的JPanel中添加了Jtable,这是一个简单的代码,但屏幕上什么也没显示。帮助。以下是我的代码:

public class AddProduct extends JFrame {

    private JPanel contentPane;
    Connection con;
    private JTable table;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    AddProduct frame = new AddProduct();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    public AddProduct() {

        con = MySQLConnection.getConnection();
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 832, 466);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(null);
        String[] column_headers = {"Team", "Pointers", "Goal Diff"};
        String[][] team_statics = {{"Man Utd", "65", "40"}, {"Chelsea", "63", "38"}};

        table = new JTable();
        table.setBounds(0, 297, 501, -296);
        contentPane.add(table);
  }
}

我正在做我在视频中看到的事情。

停止观看(仅)视频,阅读教程(例如,使用
null
布局通常不好;扩展
JFrame
不好;我从未设置过内容窗格;…)一个好的起始地址:为什么表是空的?没有数据可显示:
列标题
团队统计信息
已声明/初始化,但从未在任何地方使用。它们可能是用来作为表
table=newjtable(团队统计,列标题)的构造函数中的参数
也很难相信桌子应该有负高度
-296
!(视频/图像很适合显示GUI/菜单/…但不是阅读代码的最佳方式)谢谢大家,我发现了我的错误。问题是身高。