Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with NetBeans & JTable

Status
Not open for further replies.

Canuck2419

Programmer
May 11, 2009
3
I am having a problem extracting data from an editable
cell in a JTable. My test case is initialized with this
code snippet:
<code>
Vector <Vector> vv = new Vector ();
Vector v = new Vector ();
Vector n = new Vector ();
CrewPanel() {
v.add (1);
v.add ("d");
vv.add(v);
n.add("number");
n.add("name");
jTable1.setModel(new DefaultTableModel (vv, n));
}
</code>

With NetBeans I have marked, in the DefaultTableModel
these cells as editable. This seems to work - sort of.
If I set the value in a cell to say "a" and press a button I have installed for convenience, and inspect the dataModel,
there has been no change. OK so now I change another cell to say "b", press the button, and inspect; the first cell
update is now there but not the second. Hmm... now change the first cell to say "aa". Now the update to the second cell is there but not the second update to the first cell.
It appears to be one update behind.
My mind is dim; my spirit vexed - help me please!

Thank you for your time.
 
Assuming you've just got a plain JTable with a plain DefaultTableModel there should be no problems with this that I know of.

When you say 'inspect the dataModel', exactly how are you doing this?

Tim
 
Hello again!

Blush Blush
I spent a little time working in my other office and...

I was suffering from a little brain fade. This is the story:
Running under NetBeans in debug mode I clicked on the table cell,
entered a number , then clicked on a button. NetBeans caught the event just like I had asked & I looked at the TableModel
find out if I had got the new value. This does not work as
I thought. If I had a thought that is. JTextField, the Component that JTable uses to catch these things requires
the new value to be registered. A click on another button is
NOT good enough. TAB works, clicking on another cell in the table works, but a click on another button does not.

Simple really, if I had been awake I would have seen this...

Thank you for your time and effort!
dkr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top