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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:47:53+00:00 2026-06-07T12:47:53+00:00

I am using a TableCellEditor For my column (ButtonColumns) as follows. When i enter

  • 0

I am using a TableCellEditor For my column (ButtonColumns) as follows.
When i enter the down key the key event associated with the Jtable not fired . Please guide me regarding this obstacle, Los of Thanks in advance. The below SSCCE is as follows

class ButtonEditor_Utility extends DefaultCellEditor {

protected JButton button;



public ButtonEditor_Utility() {
button.setActionCommand(tableName);
button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            fireEditingStopped();
        }
    });
}

public Component getTableCellEditorComponent(JTable table, Object value,
        boolean isSelected, int row, int column) {
    if (isSelected) {
        button.setForeground(table.getSelectionForeground());
        button.setBackground(table.getSelectionBackground());
    } else {
        button.setForeground(table.getForeground());
        button.setBackground(table.getBackground());
    }

    label = (value == null) ? "" : value.toString();
    button.setText(label);
    isPushed = true;
    return button;
}



public boolean stopCellEditing() {
    isPushed = false;
    return super.stopCellEditing();
}

protected void fireEditingStopped() {
    super.fireEditingStopped();
}

}

 Class Test extent JFframe{

  public void    AddButtonColumn(){
 tblDetailInfo.getColumn(1).setCellEditor(
 new ButtonEditor_Utility(new JCheckBox(), this, 1, selectedRow,    this,null, "TestDB"));}

// Below Event is not responding on the Down Key
//whose key code is 40

    private void tblDetailInfoKeyPressed(java.awt.event.KeyEvent evt){                                         
    // TODO add your handling code here:
    if (evt.getKeyCode() == 40) {

        int rowId = tblDetailInfo.getRowCount() - 1;

        setSelectedRow(rowId);
        tblDetailInfo.setCellSelectionEnabled(true);
        tblDetailInfo.changeSelection(rowId, 0, false, false);
        tblDetailInfo.requestFocus();
        tblDetailInfo.scrollRectToVisible(new Rectangle(tblDetailInfo.getCellRect(rowId, 0, true)));
        AddDetailRow();

    }
}  

   private void formWindowOpened(java.awt.event.WindowEvent evt){                      AddButtonColumn(); }

public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {

            Test test = new Test();


            test.setVisible(true);
        }
    });
} }

}

  • 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-07T12:47:55+00:00Added an answer on June 7, 2026 at 12:47 pm

    Instead of trying to force a JLabel and a KeyEvent into service as a table cell editor, use an actual TableCellEditor such as @camickr’s ButtonColumn. This TableTest illustrates one way to use ButtonColumn in a JTable. The advantage is that you get all the familiar key bindings for navigation (arrow keys) and activation (space key).

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

Sidebar

Related Questions

I am using a JTable and I let the user fill it in with
I'm trying to calculate running totals using JTable and Combo combination, sometime it calculate
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using the GitHub application on Mac (not the cli), I have this error which
using chrome 15 on osx 10.6.8 When adding event listeners, I've found that putting
Using Browserlab, it appears that the background image is not centred in Firefox7 for
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
Using a populated Table Type as the source for a TSQL-Merge. I want to
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question

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.