The Artima Developer Community
Sponsored Link

Java Answers Forum
Reading the last cell in a JTable

2 replies on 1 page. Most recent reply: Sep 8, 2003 4:11 AM by mausam

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Clay Dagler

Posts: 21
Nickname: cdagler
Registered: Jul, 2003

Reading the last cell in a JTable Posted: Sep 6, 2003 1:52 PM
Reply to this message Reply
Advertisement
I made a JTable that has the user input values into the table, then when the user is done he/she hits a button to print the values in the table out to the screen. This program prints all but the last value the user input into the table. I believe this happens because a value is in a JTable is not “saved” until another cell in the table is selected. How do I fix this?

Thanks.


David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: Reading the last cell in a JTable Posted: Sep 8, 2003 3:45 AM
Reply to this message Reply
Try adding code when the Focus is lost.

mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: Reading the last cell in a JTable Posted: Sep 8, 2003 4:11 AM
Reply to this message Reply
close cell editors before leaving

   private void closeCellEditors(boolean validate)
   {
	TableCellEditor tce = null;
    	if (_table.isEditing())
   	{
       	    	tce = _table.getCellEditor();
   	}
   	if (tce!=null)
   	{
       		if (validate)
   		{
           		tce.stopCellEditing();
   		 
       		}
   		else
   		{
           		tce.cancelCellEditing();
       		}
   	}
   }
 


call this method with true value before leaving the cell and then read ur values

Flat View: This topic has 2 replies on 1 page
Topic: Need some insight into Jini technology Previous Topic   Next Topic Topic: Event Handling (not using applets)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use