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 6743985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:01:46+00:00 2026-05-26T12:01:46+00:00

In my JavaFX-program I use a TableCell where you can edit a value. Like

  • 0

In my JavaFX-program I use a TableCell where you can edit a value. Like shown at the examples on the JavaFX-page “Example”, I use this function to save the changes (function is set on TextField in edit Cell)

textField.setOnKeyReleased(new EventHandler<KeyEvent>() {
    @Override public void handle(KeyEvent t) {
    if (combo.match(t)) {
        commitEdit(textField.getText());
    } else if (t.getCode() == KeyCode.ESCAPE) {
        cancelEdit();
    }
 }

When using ENTER to leave the cell, the value is changed / saved, but how can I change / save the value, when leaving the cell by clicking in another cell? Actually the value is resetted.

Thanks
Basti

  • 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-05-26T12:01:47+00:00Added an answer on May 26, 2026 at 12:01 pm

    Listening to a change in focus on the TextField is one way.. I added a listener to the focusedProperty of the textField. The example from Oracle didn’t include this.
    [edit – here is a link to another question that has a different approach UITableView – Better Editing through Binding? ]

    private void createTextField() {
            textField = new TextField(getItem());
            textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
    
            // Detect a change in focus on the text field.. If we lose the focus we take appropriate action
            textField.focusedProperty().addListener(new ChangeListener<Boolean>() {
                public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                    if(!newValue.booleanValue())
                        commitEdit(textField.getText());
                }
            } );
            textField.setOnKeyReleased(new EventHandler<KeyEvent>() {
                @Override public void handle(KeyEvent t) {
                    if (t.getCode() == KeyCode.ENTER) {
                        commitEdit(textField.getText());
                    } else if (t.getCode() == KeyCode.ESCAPE) {
                        cancelEdit();
                    }
                }
            });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I could use a little help. I got this program to work right then
JavaFX is a new technology introduced by Sun. I would like to know what
In JavaFx i can easy create animations, moving pieces etc., but as far as
I recently started learning JavaFX. At the moment I can't build any JavaFX project
I am using the following program for sending email through Java. When I use
I would like to use JNDI to look up Kerberos SRV records in a
After a few weekends exploring Clojure I came up with this program. It allows
UPDATE: The Code working when I use it as java program. And When I
This is my program, I am using STAX Parser to parse an XML document
I making a JCurrencyField to use it in my program, I almost finished creating

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.