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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:42:19+00:00 2026-06-18T01:42:19+00:00

The flow of the program is like this : Image from 1st set of

  • 0

The flow of the program is like this : Image from 1st set of buttons (leftButtonArea) is dragged to the 2nd set of buttons (rightButtonArea).

Each image has a unique name via setName(). The name of the image that was dragged over will be compared with the name of the button which it is dragged to.

If the name matches, I wish to disable that particular button from reacting to any hover event.

.setHoverEnabled(false) doesn’t work =/

A similar SO thread regarding the disabling of event listeners, but it seems like the solutions such a using a glass pane are for whole components ?
link

Edit:
Somehow this works, but I am not sure of any side effects from this method
source.removeMouseListener(source.getMouseListeners()[1]);

Edit2:
Found something interesting.. This could be the reason why disabled buttons still reacts to mouseEvents.

“low-level: Component, Container, Focus, Key, Mouse, Paint, Window

semantic: Action, Adjustment, Item, Text

Only semantic events are affected by disabling any component. That is because they are directly handled by the component itself which is aware that it is enabled or not.
Low level events can’t be affected by disabling. If you stop to think about this when you disabled your label was it still visible. If it was then the paint event must have happened. Low level events will always happen and it is up to your handlers to query the component if it is enabled or not.”

// 1st set of 4 buttons
for(int a=0; a<4; a++){

 leftButtonArea[a] = new JleftButtonArea(new ImageIcon(image)); 

 TransferHandler transfer = new TransferHandler("icon");
 leftButtonArea[a].setTransferHandler(transfer);

 leftButtonArea[a].addMouseListener(new MouseAdapter(){
    public void mousePressed(MouseEvent e){
    JleftButtonArea leftButtonArea = (JleftButtonArea)e.getSource();
    TransferHandler handle = leftButtonArea.getTransferHandler();
    handle.exportAsDrag(leftButtonArea, e, TransferHandler.COPY);
    // get unique name for the image that is dragged
    // to rightButtonArea
    name1 = e.getComponent().getName();
    }

});

}


// creates 2nd set of 4 buttons
 for(int b=0; b<4; b++){     
     rightleftButtonAreaArea[b] = new JleftButtonArea();

     // <---- creates unique name for each leftButtonArea ----->
     cc2 += 1;
     id2+="a"+cc2;
     rightleftButtonAreaArea[b].setName(id2); 
     // <---- creates unique name for each leftButtonArea ----->

     TransferHandler transfer1 = new TransferHandler("icon");
     rightleftButtonAreaArea[b].setTransferHandler(transfer1);

    rightleftButtonAreaArea[b].addMouseListener(new MouseAdapter(){
    @Override
    public void mouseExited(MouseEvent me){
    JleftButtonArea source = (JleftButtonArea)me.getSource();

    try{
    // compare unique name of image and the button in rightButtonArea
    // if they are the same, disable hover for the button
        if( name1.equals(source.getName())){
            // this doesn't work
            source.getName().setHoverEnabled(false); 
            // Somehow this works, but I am not sure of any side effects from this 
            source.removeMouseListener(source.getMouseListeners()[1]);
        }
        else{   
            source.setIcon(null);
        }
    }
    catch (NullPointerException e) 
    {

    }

    }       

    });
}
  • 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-18T01:42:21+00:00Added an answer on June 18, 2026 at 1:42 am
    • for Buttons JComponents are MouseEvent are implemented in the ButtonModel

    • use implemented methods for Icon in the JButton API

    • examples JButton & Icon, JButton & ButtonModel

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

Sidebar

Related Questions

My program flow is like this: I need to sequential processing per user's request
I'm trying to develop a new program. The work flow looks like this: Login
My intended program flow would look like the following if it were possible: typedef
In this javascript code f.init() control the entire flow of the program: var f
I am doing some basic validation. The flow of the program goes like: User
I have the following program flow: User fills in form My app generates a
I was wondering if there is a library for editing program flow. I refer
Logical flow of the scraper: article links extracted from an XML feed are put
I am trying to make an app that plays MP3 songs. My program flow
I'm reviewing some team code and I found something like this : MyObj obj

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.