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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:25:32+00:00 2026-05-28T05:25:32+00:00

I have a custom TableCellRenderer (ValueRenderer) for a JTable, the cell is a Checkbox

  • 0

I have a custom TableCellRenderer (ValueRenderer) for a JTable, the cell is a Checkbox.

I have attached an ItemListener to the valueRenderer to listen to the checkbox’s state change (selected/deselected) as mentioned by this example.

My problem is that inside the itemStateChanged(ItemEvent e), I do not know how to get the row in which this checkbox is contained knowing that the ItemEvent source is the ValueRenderer.

Can you help me?

Here is some of my code:

Custom TableCellRender:

public class ValueRenderer extends JCheckBox implements TableCellRenderer {

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
        this.setSelected((Boolean) value);
        return this;
    }

} 

ItemListener:

public class TableRowCheckBoxListener implements ItemListener {

    private JTable hqlRequestTable;

    public TableRowCheckBoxListener(JTable hqlRequestTable) {
        this.hqlRequestTable = hqlRequestTable;
    }

    @Override
    public void itemStateChanged(ItemEvent e) {

        /*How do I get the row which contains the checkbox clicked knowing that :
            e.getSource() == ValueRenderer
            e.getItem() == ValueRender
        */
    }

}
  • 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-28T05:25:32+00:00Added an answer on May 28, 2026 at 5:25 am

    If you want to know when some value changes in your table, you must not register a listener on the renderer. You must register a listener on the table model: that’s where the data displayed by the table is held, and that’s the object which fires an event if anything changes in the data.

    The alternative is to use a custom table model consisting in a list of beans, have the table model modify the properties of the beans it holds, and have the bean fire a property change event when a property changes. You’ll then register listeners on the beans themselves rather than registering a table model listener (note that the table model still has to fire table model events, though).

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

Sidebar

Related Questions

I have a custom cell renderer set in JTable and it works but instead
I have a JTable with a custom TableCellRenderer and a custom TableCellEditor . By
I have custom groupViews that need to change state when they are expanded and
I have a JTable with a custom Cell Renderer for multi-line cells. Everything is
I have a JTable with custom TableCellRenderer. public class DateCellRenderer extends DefaultTableCellRenderer { private
i have custom cell with 2 buttons(the function of these buttons is just to
I have custom cell which contains number of rows in it.i want to write
I have custom buttons in the nav bar, I want to toggle their state
I have custom table view cell with images (loaded from app document directory), labels,
I have a custom renderer in a JTable . When my JTable displays, I

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.