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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:51:18+00:00 2026-05-28T20:51:18+00:00

I am wanting to use a JTable but with a different cell selection method

  • 0

I am wanting to use a JTable but with a different cell selection method rather than clicking in the cells. I am using the glasspane to allow users to draw a rectangle and am discovering what cells are contained in the rectangle to select. But I am only wanting to select a cell if it is totally within the rectangle. For example, imagine a simple 3 x 3 table. The user my want to select the middle cell (1,1). I want them to be able to click in the first cell 0,0 and drag down to cell 2,2 drawing the rectangle for selection. But I don’t want cells 0,0 or 2,2 selected. Or get all 9 selected, for that matter. This is a simplified example. Drawing the rectangle might actually encompass cells from more than one table on the screen.

I looked into implementing the ListSelectionModel interface, but don’t really want to try and rewrite that. While experimenting I saw that setSelectionInterval() in the model was being called like crazy (for every single mouse movement) as I click and dragged around in the table. What I would really like is to find a simple way to turn off whatever listener/mechanism is on the table that makes the calls to the SelectionModel, while keeping the model in place. I’d still want it to report isSelectedIndex() for example. I would tell the model what intervals are selected.

I figured that somewhere there’s a mouse input adapter inherently built into JTables? I’d like to turn it off if possible.

Thanks,
BBB

  • 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-28T20:51:19+00:00Added an answer on May 28, 2026 at 8:51 pm

    For a generic / text-based question, you get a generic, text-based response. 🙂 Start by uninstalling the MouseListeners installed on the table by default:

    MouseListener[] listeners = myTable.getMouseListeners();
    for (MouseListener l : listeners)
    {
        myTable.removeMouseListener(l);
    }
    

    Then, add your own MouseListener to the table (use MouseAdapter if you want) and override the “mousePressed” / “mouseReleased” methods to record the points where the drag began, and drag ended. Determine the enclosing rectangle and call:

    setRowSelectionInterval(#, #)
    setColumnSelectionInterval(#,#)
    

    to select one (or more) cells.

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

Sidebar

Related Questions

I am wanting to use the Facebox plugin for JQuery but am having a
I'm wanting to use an extension for Python that I found here , but
I've got a full layout designed using 960.gs and am wanting to use it
Wanting to use: Ajax Event Calendar but the dates are in american format, how
I'm wanting to use QuickGraph to draw some graphs in C# using GraphViz. I've
I am wanting to use core plot but before I work on implementing it,
I am wanting to use the phonegap audio api in GWT using JSNI.I cannot
I am wanting to use MongoDB on my Windows Server and I am using
I'm wanting to use a datasource to go through records but one at a
I'm wanting to use DB4o on an asp.net MVC project i'm working on but

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.