Is this your first time here? SwingWiki is a Java Swing Developer community site with an big archive of Swing-related usenet groups and mailing lists, but also tips, tricks and articles and book reviews written by your colleagues from around the world. If you came here through a search engine and did not find what you were looking for, make sure to check the wiki table of contents.

Always save interactive table editing

With tables that can be edited by users, most applications provide a “Save” button. If the user is editing a cell when he presses the “Save” button, the content of the TableModel does not match the content on the screen (currently edited cell is not saved to the Table Model yet). Always remember to de-activate the editor before actually processing the Table Model.

table.getDefaultEditor(Object.class).stopCellEditing();

Maybe a better approach is to use the following code. One reason, it’s a lot more general - what if the current editor isn’t for the Object class.

if (table.isEditing())
    table.removeEditor();
 

Comments? Corrections? Contact us or Login to edit pages directly (registration is free and takes less than displaying a JLabel)
  best/always_save_interactive_table_edit.txt · Last modified: 2005/05/09 13:29 by 146.197.27.16 (neilw)
 
Recent changes | RSS changes | Table of contents | News Archive | Terms And Conditions | Register | The Quest For Software++| Ruby Resources

Sedo - Buy and Sell Domain Names and Websites project info: swingwiki.org Statistics for project swingwiki.org etracker� web controlling instead of log file analysis