Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8696523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:17:30+00:00 2026-06-13T01:17:30+00:00

I am having the following issue: I have a JTable with its on tablemodel

  • 0

I am having the following issue: I have a JTable with its on tablemodel sitting on a JFrame. The tablemodel is backed up with an own hashmap to store the contents. The table has two columns where the right one is editable.

Normally the user changes some value on the right then presses the enter button which fires the tabledatachanged event that calls my saving function. Then the frame can be closed.

However, some users just simply edit the cell and then they close the window without pressing enter so I get no chance to save the table. I know how to write events when the frame is about to be closed, but I do not know how to retrieve the content of the “unfinished” editing while also finalizing that edit.

I guess it has something to do with the celleditors, I even tried with the table.getCellEditor() that should return the active one but instead it returns null.

Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:17:31+00:00Added an answer on June 13, 2026 at 1:17 am

    The most simple measure is to configure the table to do its best effort when loosing focus:

    table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    

    Unfortunately, there are contexts when its best effort is not good enough (f.i. when the user clicks the close button of a frame). In those, there is no way but to hook into each and every lane that might loose the edit and manually force the edit to stop

    if (table.isEditing()) {
        boolean stopped = table.getCellEditor().stopCellEditing();
        if (!stopped) {
            // here goes error handling and/or cancelling the edit
        }
    }
    

    From your description of the problem,

    some users just simply edit the cell and then they close the window without pressing enter

    I’m slightly surprised the the first is working, would have expected that you needed doing the second in a WindowListener.

    See also Rob’s blog entry

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having the following issue: I have a tab-style app. Eacht tab has its
I'm having the following issue: I have a trigger on a table A, whose
I'm having the following issue with WCF RIA Services: I have a table Customer
I am having the following issue : I have a table which looks like
I am having following issue with reading binary file in C. I have read
I'm designing a mySQL DB and I'm having the following issue: Say I have
We are having an annoying issue with Firefox and cookies. We have the following
I am having trouble with the following SQL statement. I have had this issue
I'm having an issue with rails involving javascript. Basically, I have the following code:
I'm having the following issue developing in android 2.2 (API 8): I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.