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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:44:57+00:00 2026-05-13T10:44:57+00:00

The desired behavior is akin to the mirrored text editing field provided in Excel

  • 0

The desired behavior is akin to the mirrored text editing field provided in Excel when a given cell is selected, allowing more space to view the contents of the cell. I have a JTable with 5 columns and n rows. Column 2 holds expressions that can be arbitrarily long, thus I’d like to provide a separate JTextField to work with for editing the contents of the expression cell per row. The other fields are directly editable in the table. When the user clicks on a field in column 2, however, I want to send them to the text field. Any contents preexisting in the cell should be appear in the text field and additional edits in the text field should be mirrored in the table cell. Likewise, if someone double-clicks on the cell and edits it directly, I want those changes reflected in the text field. Thus, the user can choose to edit in either space and both are updated. Ideally, they are updated per keystroke, but update upon hitting return is acceptable.

So, far I’ve got the JTable, TableModel, TableModelListener, JTextField, ListSelectionListener, and AbstractAction, working together to provide most of the functionality described above. I’m missing the reflection of direct table cell edits to the text field and per-keystoke updates.

Are their ideas on how best to construct this behavior?

  • 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-13T10:44:57+00:00Added an answer on May 13, 2026 at 10:44 am

    Well, if you want to get data from the table to the cell then you add the code to your TableModel’s setValueAt() function, which should run when the user changes the content in an editable cell. I don’t think that will update per-keystroke though.

    If you want to move data from the textbox to the table cell use code like this

    myJTextField.getDocument().addDocumentListener(new MyDocumentListener());
    

    Where MyDocumentListener is an implementation of the javax.swing.event.DocumentListener interface

    That will get you per-keystroke updates from the box to the table. But for the other way around it’s a bit trickier.

    There are two ways you might be able to go about doing it

    1) Add a key listener to the table, and when the user starts typing check to see what table element is active, and intercept keystrokes as they type. That’s kind of messy, though.

    2) Another option might be to try to grab or replace the component that the table is using to actually let the user make the changes. I think that JTable actually allows you to change the editor component if you dig around.

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

Sidebar

Related Questions

I want to create super script for desired text selected by user. I found
Desired behavior: In Clojure's implementation of Agents, to update an Agent, one does NOT
Here is my desired transaction order: User1 select field, perform operation, update with new
Example of failure: http://progamonth.com/files/testfile.html Desired Behavior: Ideally, any headers with a colspan shouldn't affect
Desired Behavior: After using the Like button on top of my fan page, I
I have the following marquee: <div id=tip><marquee loop=1 direction=right behavior=slide>Text</marquee></div> The above code moves
Is it normal that the default behavior for code completion when editing Java is
I'm having trouble getting desired behavior in a WPF RichTextBox. I am creating a
Desired behavior An undecorated non-nullable value-type property in a model automatically gets a validation
I am having problems getting the desired behavior out of these few classes and

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.