关于Java / Eclipse / Windowbuilder没有得到值的奇怪错误?

时间:2017-02-04 20:02:42

标签: java swing label awt windowbuilder

我有一个非常奇怪的问题..“getValueAt”方法返回除频率1之外的值 - 它返回null。我不明白为什么作为表中的一个方法。有人知道为什么吗?

JButton btnAdd = new JButton("Add ");
    btnAdd.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
            lblWeSuggestThe.setText(woooord);;
            id.add(table_1.getValueAt(0,0)+"");
            forename.add(table_1.getValueAt(0,1)+"");
            surname.add(table_1.getValueAt(0,2)+"");
            address.add(table_1.getValueAt(0,3)+"");
            frequency.add(table_1.getValueAt(0,4)+"");
            JLabel lblWeSuggestThe = new JLabel("We suggest the use of ID " + (id.size() + 1) + ".");
                try {
                    FileWriter fw = new FileWriter ("southbank.csv", true);
                    fw.write("\n" + table_1.getValueAt(0,0) + "," +table_1.getValueAt(0,1) + "," +table_1.getValueAt(0,2) + "," +table_1.getValueAt(0,3) + "," +table_1.getValueAt(0,4) +"");
                fw.close();
                    } catch (IOException e1) {

                        e1.printStackTrace();
                    }

                }
            });

*

1 个答案:

答案 0 :(得分:-1)

对于将来出现此问题的用户,必须在输入最终值后按Enter键或单击与输入数据不同的列,因为数据未获得SET。

例如,在输入第五个也是最后一个条目后单击第四个条目。