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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:25:35+00:00 2026-06-03T09:25:35+00:00

I right clicked the JTable and inserted some code into post listeners code in

  • 0

I right clicked the JTable and inserted some code into “post listeners code” in an awful kludge.

I don’t see an option to add

table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
  public void valueChanged(ListSelectionEvent evt) {

to “events” in the “design” view for the JTable. I’m sure there’s a way to add a valueChanged(ListSelectionEvent evt) from design view, but how?

maybe it’s a bug?

Row selection change events are produced by ListSelectionModel of
JTable, not by JTable itself – so the event cannot be presented in
Component Inspector (as event of JTable). Handling this event must be
done manually, e.g. like:

jTable1.getSelectionModel().addListSelectionListener(
    new javax.swing.event.ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            customRowSelectionEventHandler(evt);
        }
    }
);

Although maybe there’s a way to get the ListSelectionModel for a JTable outside of the “blue”, “managed,” code?

  • 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-03T09:25:37+00:00Added an answer on June 3, 2026 at 9:25 am

    You can create your own ListSelectionListener in the editable part of the source. You can add an instance of the listener to the selection model of the class variable jTable1 in your table’s Post-init Code property:

    jTable1.getSelectionModel().addListSelectionListener(new MyListener());
    

    The listener itself might look like this:

    private static class MyListener implements ListSelectionListener {
    
        @Override
        public void valueChanged(ListSelectionEvent e) {
            System.out.println(e.getFirstIndex());
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code right now that executes when a link is clicked. The
I want to add a right click popupmenu to a JTable in NetBeans IDE
The build path option is not available when I right clicked on one of
Made a new window application. Right-clicked Frameworks > Add Existing Frameworks. Selected Frameworks folder,
When you selected text in the code window and right-clicked on it, you would
In Excel 2007, I inserted an ActiveX label onto my worksheet. I right-clicked on
Here's what I did: Right-clicked on an item in the 'Objects and Timeline' panel.
problem is , that whenever the grid's row is right clicked the selected item
I right clicked on a Database in the object explorer of SQL Server 2008
Short version of the question: Since I already have TortoiseHg, I right clicked on

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.