Skip to main content

Getting integer values from a JTable

1 reply [Last post]
zikojam
Offline
Joined: 2008-12-11
Points: 0

Hello

The table's cells contain integer values. I would like to save each one of theme them in an array of integers.
The problem is, I don't know how to do so. I tried to use the getValueAt method, but I always get error messages.
I tried something like:
Object o = table.getModel().getValueAt(i, j);
a[x]=Integer.parseInt(o.toString());

When I made a test to make sure that the data are well stored.
JOptionPane.showMessageDialog(null, a[0]);
System.exit(0);

The IDE hangs.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

Please help.
Thank you.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
walterln
Offline
Joined: 2007-04-17
Points: 0

You already posted your question [url=http://forums.sun.com/thread.jspa?threadID=5354464&messageID=10541677#10541677]here[/url].