cosutomize code with guid builder problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

cosutomize code with guid builder problem

blob84
I have added a Jtable to a JScrollPane.
I need to add an event to a button to insert a new row dinamically.
The generated code is
Code:
jTable1 = new javax.swing.JTable();

jTable1.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
        {null, null, null},
        {null, null, null},
        {null, null, null},
        {null, null, null}
    },
    new String [] {
        "Sport passati", "Per quanto tempo", "Tempo di inattività"
    }
) {
    Class[] types = new Class [] {
        java.lang.String.class, java.lang.String.class, java.lang.String.class
    };

    public Class getColumnClass(int columnIndex) {
        return types [columnIndex];
    }
});



jScrollPane1.setViewportView(jTable1);



So I should create a new private variable and store the DefaultTableModel object.
The new code is :


Code:
jTable1 = new javax.swing.JTable();

jTable1.setModel(dmt1 = new javax.swing.table.DefaultTableModel(
    new Object [][] {
        {null, null, null},
        {null, null, null},
        {null, null, null},
        {null, null, null}
    },
    new String [] {
        "Sport passati", "Per quanto tempo", "Tempo di inattività"
    }
) {
    Class[] types = new Class [] {
        java.lang.String.class, java.lang.String.class, java.lang.String.class
    };

    public Class getColumnClass(int columnIndex) {
        return types [columnIndex];
    }
});



jScrollPane1.setViewportView(jTable1);


and

Code:
private javax.swing.table.DefaultTableMode dmt1;


After this changes the table disappear.
What's wrong?
I'm using netbeans 8.1 under Debian 9.