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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:50:56+00:00 2026-05-23T10:50:56+00:00

in a jTable, I want when a user clicks on a cell, this sentence

  • 0

in a jTable, I want when a user clicks on a cell, this sentence to be printed on the screen :

I am cell in row X and column Y

where x and Y are the row and column of the clicked cell.
But what I am getting is : when I click for example the cell in row 1 and column 4
I get the following :

I am cell in row 1 and column 0
I am cell in row 1 and column 1
I am cell in row 1 and column 2
....
I am cell in row 1 and column N  ( N = number of columns)

i.e. the whole row is selected.

this is the code :

public class CustomTableCellRenderer extends DefaultTableCellRenderer{

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{

    Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

            if(isSelected) System.out.println("I am cell in row "+row+" and column "+column);



    return cell;

}

}

Thanks for any help.

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

    CellRenderers are used for rendering the cell contents. If you want to find the cell in which the mouse clicked, use a MouseListener and in the mouseClicked method find the cell.

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

Sidebar

Related Questions

I have a JTable and i want a cell (or its row) painted in
I have a JTable . I want to know which row and column are
I want to implement DropTargetListener with a JTable as a target. This is roughly
Suppose you have a JTable and for each cell you want to display three
I know that JTable can sort by a single column. But is it possible
In a JDialog, when user clicks a JButton i want to execute 2 GUI
I need to store a mouse click event whenever a user clicks on a
can anyone help me with this , I have a jtable and I want
I have a Jtable and I want to highlight a row by adding a
i have a jtable and i want when selecting a cell to change the

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.