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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:44:42+00:00 2026-05-20T13:44:42+00:00

I have a map applet, and I have a JLabel following the mouse, whenever

  • 0

I have a map applet, and I have a JLabel following the mouse, whenever the mouse goes over a city the JLable displays the the name of the city and population.

I use the mouseMotionListener’s MouseMoved method for that, but i want the label to be there only if the mouse stays still for a couple of seconds above the city.

I dont know if its because I been working on this code for days now, but i cant seem to think of a solution for this using the MouseMoved method, i tried using timers but that didnt work for me (mayb i just did it wrong cause my brain is burned out)

so is there a mouse listener for the mouse staying still? or do you have any recommendations?

here is more or less what I got

public void mouseMoved(MouseEvent evt) {
   int x = evt.getX();
   int y = evt.getY();
   boolean aboveCity = false;
   mouseover.setBounds(x+20, y-10, 200, 20); //mouseover is a JLabel

   for (int i=0;i<cityCounter;i++){
      if (city[i].containsPoint(x,y){
         name = city[i].getName();
         population = city[i].getPopulation();
         aboveCity = true;
      }
   }
   if(aboveCity){
      mouseover.setText(name + ", " + population);
   }
   else{
      mouseover.setText("");
   }
}
  • 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-20T13:44:43+00:00Added an answer on May 20, 2026 at 1:44 pm

    Use a Java javax.swing.Timer. Each time the mouse moves, reset the timer. When the timer goes off, the mouse has been “still” for as long as your timer was set for.

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

Sidebar

Related Questions

I have a Java applet which displays an interactive map. By using the scroll
I have map.resources :posts and I want to be able to serve post bodies
I have map with multiple different colors markers with some info window. Everything works
I want to display google map in Android ,i have map API even map
I have a Map and a List . The List should be sorted based
I have a map of the UK broken down into various geographic regions. I
I have a map that i want to update from a separate thread. Im
I have a map with various markers and i need to be able to
I have image map that can I move, but this map will be so
I have a map<int int> . I need to get a vector of 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.