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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:58:28+00:00 2026-05-15T02:58:28+00:00

I added a mouse clicked listner to my jtable, when i double click the

  • 0

I added a mouse clicked listner to my jtable, when i double click the row, will pop up an window accordingly.

jTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent e) {
double amount = Double.parseDouble(jTable.getValueAt(getSelectedRow(), 4).toString());
String remarks = jTable.getValueAt(getSelectedRow(), 3).toString();
String transactionID = jTable.getValueAt(getSelectedRow(), 1).toString();
        new EditFrame(...)
}
});

This code I used to retrieve the row selected row.

public int getSelectedRow() {
jTable.getSelectionModel().addListSelectionListener(
new ListSelectionListener() {
 public void valueChanged(ListSelectionEvent event) {
  int viewRow = jTable.getSelectedRow();
  selectedRow = viewRow;
  System.out.println(viewRow);
 }
});
return selectedRow;
}

In my case, I realised when I clicked the second row in the first time, I get null for selectedRow, only when I select first row then second row, I then can get the correct data. And If I removed the mouse listener the problem then be solved. Is it because I doing something wrong at the mouse click listener?

  • 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-15T02:58:29+00:00Added an answer on May 15, 2026 at 2:58 am

    If you just want to know what row was clicked then you don’t need the selection listener. Just use:

    table.rowAtPoint();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Flash 11.2 added the capability to attach an right-click mouse-event to MovieClips. EX: var
i have a jsp where i have added a logo. on click/on mouse hover
I added the following code as a listener to JTableHeader: header.addMouseListener(new MouseAdapter() { @Override
What is the solution to this problem? I added a mouse listener to a
I added Jquery toggle/show hide in my site (click the plus sign) http://pligg.marsgibson.info if
I have added a border to a button on mouse hover but this disturbs
I'm trying to catch a mouse-click even on a Table (which should cause a
I have text widgets that can be added on the page. A click should
I have a table-row that has a JavaScript action attached to mouse clicks anywhere
I am using java. I have a click event that adds squares to 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.