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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:21:38+00:00 2026-05-25T13:21:38+00:00

Problem I want the capabilities of JXTable with the select all on edit behavior

  • 0

Problem

I want the capabilities of JXTable with the “select all on edit” behavior of RXTable. Doing a simple override would be fine but the double click function of the RXTable doesn’t work with JXTable. When using the Button Action mode it’s fine, but when using F2 or a double click something in JXTable clashes with RXTable and remove the selection so I’m left with default behavior. Is it because of the GenericEditor that it uses internally or is it something else?

How can I get JXTable to select all on F2 or double click edit?

EDIT: It looks like this only happens when the model has the column defined for type Integer. It works as expected when it is defined for a String or Object column.

Solution

Thanks to kleopatra’s fix I was able to alter the selectAll method so it handles JFormattedTextFields and all cases of editing. Since the original code worked on type to edit I just used the fix for other cases. Here is what I ended up with.

Replace selectAll in RXTable with the following:

/*
 * Select the text when editing on a text related cell is started
 */
private void selectAll(EventObject e)
{
    final Component editor = getEditorComponent();

    if (editor == null
        || ! (editor instanceof JTextComponent 
                || editor instanceof JFormattedTextField))
        return;

    if (e == null)
    {
        ((JTextComponent)editor).selectAll();
        return;
    }

    //  Typing in the cell was used to activate the editor

    if (e instanceof KeyEvent && isSelectAllForKeyEvent)
    {
        ((JTextComponent)editor).selectAll();
        return;
    }

    // If the cell we are dealing with is a JFormattedTextField
    //    force to commit, and invoke selectall

    if (editor instanceof JFormattedTextField) {
           invokeSelectAll((JFormattedTextField)editor);
           return;
    }

    //  F2 was used to activate the editor

    if (e instanceof ActionEvent && isSelectAllForActionEvent)
    {
        ((JTextComponent)editor).selectAll();
        return;
    }

    //  A mouse click was used to activate the editor.
    //  Generally this is a double click and the second mouse click is
    //  passed to the editor which would remove the text selection unless
    //  we use the invokeLater()

    if (e instanceof MouseEvent && isSelectAllForMouseEvent)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            public void run()
            {
                ((JTextComponent)editor).selectAll();
            }
        });
    }
}

private void invokeSelectAll(final JFormattedTextField editor) {
    // old trick: force to commit, and invoke selectall
    editor.setText(editor.getText());
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            editor.selectAll();
        }
    });
}
  • 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-25T13:21:39+00:00Added an answer on May 25, 2026 at 1:21 pm

    a quick hack working for two of the three selection types

           // in selectAll(EventObject) special case the formatted early
           if (editor instanceof JFormattedTextField) {
               invokeSelectAll(editor);
               return;
           }
    
    
            private void invokeSelectAll(final JFormattedTextField editor) {
                // old trick: force to commit, and invoke selectall
                editor.setText(editor.getText());
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        editor.selectAll();
                    }
                });
            }
    

    was remembered of the trick by How to select all text in a JFormattedTextField when it gets focus? – doesn’t handle the case when starting edit by typing, in this case the content is not deleted (as for a normal textfield) but the new key is added.

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

Sidebar

Related Questions

Really simple problem: I want to split a connection string into its keyword /
I have a rather simple C++-problem, but coming from a C-background I am not
Problem: I want to get all locations from a database and encase them all
I'm learning ASP.NET MVC3 and doing an application with CMS capabilities - but have
This is strange problem. I want to use easyuis drad-and-drop capabilities, so I need
Should be an easy one, but it's past my bedtime: Problem: Want to type
Problem: I want to list n number of games from each genre (order not
Problem: I want my unicode characters to be stored on disk as (rather tan
The problem: We want to bind a HierarchicalDataTemplate’s ItemsSource property to a CollectionViewSource, to
Core problem: I want to be able to take an instance of a templated

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.