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

  • Home
  • SEARCH
  • 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 706291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:08:58+00:00 2026-05-14T04:08:58+00:00

This may be a stupid question, but I have to ask! I have the

  • 0

This may be a stupid question, but I have to ask!

I have the following code snippets that are supposed to run their corresponding methods when the user interacts with objects.
For some reason, “foo” is never printed, but “bar” is.

myJSpinner1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseEntered(java.awt.event.MouseEvent evt) {
    System.out.println("foo"); //"foo" is not printed
  }
});

myJSpinner2.addChangeListener(new java.awt.event.ChangeListener() {
    public void stateChanged(java.awt.event.ChangeEvent evt) {
    System.out.println("bar"); //"bar" is printed
  }
});

I get no exceptions or stack trace. What am I missing in the MouseListener one?
Thanks in advance.

EDIT: MouseEntered works perfectly on a JCheckBox implemented in exactly the same way!

  • 1 1 Answer
  • 2 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-14T04:08:59+00:00Added an answer on May 14, 2026 at 4:08 am

    JSpinner is a composite component consisting of a text field and 2 buttons. It’s possible to add mouse listeners to all of those by iterating over the results of getComponents() and adding a listener to each.

    However, in my experience, when something takes that much work, you’re probably going about it the wrong way.

    Why do you need the mouse-entered information for a JSpinner?
    What do you want to do with this event?

    Update:
    If you’re looking to supply information about all of the controls in your panel, you may want to look at using a glasspane to detect the component under the mouse.

    A Well-behaved Glasspane by Alexander Potochkin is a good place to start.

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

Sidebar

Related Questions

This may be a stupid question but I have a code with the following
This may be a weird or stupid question, but I have the following code
I know this may be a stupid question to ask but I have really
This may be an incredibly stupid question, but I have a web application that
This may be a stupid question but I will ask it anyway. I have
I'm not a DBA so this may be a stupid question but I'll ask
This may be a stupid question to ask, but still I need to know
This may be a pretty naive and stupid question, but I'm going to ask
This may be a stupid question but one that is throwing me for a
this may be a stupid question or a typo but I'm going to ask

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.