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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:30:55+00:00 2026-05-15T09:30:55+00:00

I am adding a label to a JTable and adding mouseMotionListener event to the

  • 0

I am adding a label to a JTable and adding mouseMotionListener event to the label.The label moves across the table on mouseDragged event.The table contains more than 50 columns and only 15 columns will be visible at any point of time.Now if I want to move the label to the other side of the same row I can’t move the label without moving the scroll bar manually.Is it possible to move the scrollbar automatically simply on dragging the label?

JTable table = new JTable(model);
JLabel label = new JLabel();
label.setBounds(100,50,80,20);
table.add(label);
label.addMouseMotionLister(new MouseMotionListener()
{
public void mouseDragged(MouseEvent arg0)
{
label.setBounds(label.getX()+arg0.getX(),Y,width,height);
}
  • 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-15T09:30:56+00:00Added an answer on May 15, 2026 at 9:30 am

    Invoke scrollRectToVisible(…) on the table after you move the label. You should be able to use the bounds of the label as the Rectangle for the method.

    Edit:

    Converting the above suggestion in english to Java code I would try something like:

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

Sidebar

Related Questions

Adding more than one child to a WPF StatusBar results in poor layout with
I am putting a label on a UIToolbar (per this tip: Adding a UILabel
I'm not having much luck centering vertically the label I'm adding to the TitleView
Adding more and more configurations to my servlet container ( Embedded Jetty in my
i am adding a label to camera overlay and i successfully added it but
In my application I'm adding a label to tableView cells using cell addsubview and
I searched for tutorials for adding button in jtable and found a class file
I'm currently adding a tooltip to a label like so: ToolTip LabelToolTip = new
I'm adding tags to a label on click by doing the following in jQuery
I'm currently adding custom label controls dynamically at runtime in my WPF app. I've

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.