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

  • Home
  • SEARCH
  • 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 8449955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:50:31+00:00 2026-06-10T10:50:31+00:00

JTable’s default behavior is changing focus to next cell and I want to force

  • 0

JTable’s default behavior is changing focus to next cell and I want to force it to move focus to next component (e.g. JTextField) on TAB key pressed.
I overrided isCellEditable method of DefaultTableModel to always return false:

public boolean isCellEditable(int rowIndex, int columnIndex) {
    return false;
}

But it still doesn’t change focus to next component!
How should I make JTable change focus to next component instead of next cell?

  • 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-10T10:50:33+00:00Added an answer on June 10, 2026 at 10:50 am

    If you really want this, you need to change the default behavior of the tables action map.

    ActionMap am = table.getActionMap();
    am.put("selectPreviousColumnCell", new PreviousFocusHandler());    
    am.put("selectNextColumnCell", new NextFocusHandler());    
    

    Then you need a couple of actions to handle the traversal

    public class PreviousFocusHandler extends AbstractAction {
        public void actionPerformed(ActionEvent evt) {
            KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
            manager.focusPreviousComponent();
        }
    }
    
    public class NextFocusHandler extends AbstractAction {
        public void actionPerformed(ActionEvent evt) {
            KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
            manager.focusNextComponent();
        }
    }
    

    Another approach would be to disable the underlying Action…

    ActionMap am = table.getActionMap();
    am.get("selectPreviousColumnCell").setEnabled(false);
    am.get("selectNextColumnCell").setEnabled(false);
    

    (haven’t tested this)

    The benefit of this approach is can enable/disable the behaviour as you need it without needing to maintain a reference to the old Actions

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

Sidebar

Related Questions

In Jtable when Tab key is pressed the focus shifts to the next cell
Suppose you have a JTable and for each cell you want to display three
I use JTable GUI component with NetBeans. I want to create multi-line headers I
JTable cells by default are in append mode when the cell is double clicked
I have an editable JTable . If a user is editing a cell when
I have created one jTable. I want to display the data into table from
I want a JTable to be populated with certain information. That information (i.e the
I have a JTable which I want to have left-click and right-click JPopupMenu on
I have a JTable with JLabel[][] as data. Now I want to detect a
I have a Jtable and I want to highlight a row by adding 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.