Help..Getting Null Pointer Exception when accessing last value in a table

View: New views
2 Messages — Rating Filter:   Alert me  

Help..Getting Null Pointer Exception when accessing last value in a table

by jdnc-interest :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi
   I have a jframe with a table and a button to add the values from table into a doucment. Here is the code i used..

 for(int i = 0; i<rowCount; i++){
                    try {
                        document = document + "\n" + (i+1)+". "+((javax.swing.table.DefaultTableModel)tblMatching.getModel()).getValueAt(i, 0).toString()+"::"+((javax.swing.table.DefaultTableModel)tblMatching.getModel()).getValueAt(i, 1).toString();                      
                    }
                    catch(Exception e) {
                        javax.swing.JOptionPane.showMessageDialog(this,"Please don't leave the Question or Answer column blank."+e);
                        return;
                    }                    
                }


After entering the values in the table and I click the Add button,
In the last row, last column  a null value is returned.
But after changing the focus to any other cell, I'm able to get the correct values.

Can somebody help me why this is happening ??
Please help me to sort out this problem !!
[Message sent by forum member 'javapedant' (javapedant)]

http://forums.java.net/jive/thread.jspa?messageID=285676

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...


Re: Help..Getting Null Pointer Exception when accessing last value in a table

by Kleopatra :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

jdnc-interest@... schrieb:
> Please help me to sort out this problem !!
>  

which is related to SwingLabs/SwingX in that...?? For basic questions,
please choose one of the general forums, this here is highly
specialized, Swinglabs only, strictly, no exceptions.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@...
For additional commands, e-mail: jdnc-help@...

LightInTheBox - Buy quality products at wholesale price