Netbeans - Java - GUI - 表格Swing

时间:2014-12-05 00:47:40

标签: java swing netbeans jtabbedpane

我有一个问题,它会让我发疯,我有一个表单,用户输入数据到该表单,然后提交表单,我想将该信息添加到表格,但平板电脑永远不会更新。 这是submition按钮的文档:

private void submitButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                                 
    try {
        if ((textboxTemperaturaPrevistaParaHoje.getText().equals(""))
                || textboxVelocidadeDoVento.getText().equals("")
                || textboxTeorDeHumidade.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "All fields must be filled!", "ERROR!!!", WIDTH);
        } else {
            try {
                DefaultTableModel model = (DefaultTableModel) jTable2.getModel();
                model.addRow(new Object[]{textboxVelocidadeDoVento.getText(), textboxVelocidadeDoVento.getText(), textboxVelocidadeDoVento.getText(), textboxVelocidadeDoVento.getText()});
                jTable2.setModel(model);
                JOptionPane.showMessageDialog(null, dadosObtidos, "Submited with sucess!", WIDTH);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Error while updating table!", "ERROR!!!", WIDTH);
            }
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Enter an valid date!", "ERROR!!!", WIDTH);
    }
}

这是表格:

这是我要更新的表格:

请帮帮我。

0 个答案:

没有答案