Action when mouse is held down over graphical elements

Hi All,
I need the colour of a load of circles to change when the mouse is pressed and hovering over them. (Not just when mouse clicked)
Here my code for colouring when clicked :
public void mousePressed(MouseEvent e) {
int circleIndex = -1;
for (int i = 0; i < v.size(); i++) {
Ellipse2D aCircle = (Ellipse2D) v.elementAt(i);
if (aCircle.contains(e.getX(), e.getY())) {
System.out.println("You clicked inside the NEW circle");
circleIndex = i;
on[i] = circleIndex;
System.out.println("on[i] : " + on);
repaint();
System.out.println("index = " + circleIndex);
Thanks in Advance

This will help, but you will have to add code for 'hovering'. (If you search the forums, I'm pretty sure someone has done it before)
http://java.sun.com/docs/books/tutorial/uiswing/events/mousemotionlistener.html

Similar Messages

  • Kill the MouseEven.CLICK event when mouse is held down?

    I have been studying games on Facebook and am trying to emulate mouse event handling. For example in ChefVille you can click on objects and drag them around. But if you hold the mouse down you pan the entire game environment and when you release the mouse button a click is NOT registered on the object below the mouse. In my tinkering the CLICK event is triggered on the release of the mouse button no matter how long I keep the button depressed. How do I keep the CLICK event from firing if the mouse is held down for some period of time?

    I don't know that you can cancel a CLICK event in the middle of it happening (CLICK = MOUSE_DOWN followed by MOUSE_UP), but you can trigger a Timer on the MOUSE_DOWN event and use its event handler to set a boolean variable that your CLICK event handler function can make use of to decide whether or not to process a CLICK event.

  • How to highlight cell in a tree programatically when mouse arrow is moved over it

    Hi
       I would like to highlight a particular cell in a tree when a mouse arrow is moved over it. Similar to wndows drop down menu. Can anybody help me on these.
    Regards
    Bharath
    Solved!
    Go to Solution.

    But I find an issue with this. When there are items with same values in the tree, it always points to the first matched value (even if I set the active item tag to the one where I want to point to). For example, if I have  a tree with values "Hello, Hi, Bye, Hello" and then I set the value to "Hello", it points to the first "Hello" even if I set the tag to the second yellow. Do you know any easy work around for this? Thank you!
    jcarmody wrote:

  • Safari 5.1 flash mouse_leave not fired when mouse button is down

    Hi all, anyone know a work around for the fact that Event.MOUSE_LEAVE is not fired in Safari 5.1 (OSX 10.6.8) if the mouse button is down? I tried the latest beta player and the issue is not resolved. Thanks!

    WOT alerts you to dangerous web sites.
    That function is already built into Safari, and has been since version 3:
    http://www.macworld.com/article/137094/2008/11/safari_safe_browsing.html
    I had never heard of the WOT extension until today!
    If you go to Safari Preferences/Security you will see a box marked 'Warn when visiting a fraudulent website'. That is what that is.
    The blacklists from Google’s Safe Browsing Initiative (where Safari checks for 'fraudulent websites') are contained in a database cache file called SafeBrowsing.db  - the file was created when you first launched Safari, and if you have the browser open, the file is modified approximately every 30 minutes.

  • How to cause a menu to display when spacebar is held down?

    Hi, is it possible to make a menu display when the spacebar is held down, then, disappear once a menu option is chosen and the spacebar is released? 
    Thanks

    Here's some code that will make a named object appear/disappear with the spacebar.  But it is not currently dependent on selecting something from the object, such as a menu option.
    stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
    menu.visible = false;
    function keyDownHandler(evt:KeyboardEvent):void {
    if(evt.keyCode == 32 && evt.type == "keyDown"){
      trace("Space pressed down");
      stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
      stage.addEventListener(KeyboardEvent.KEY_UP, keyDownHandler);
      menu.visible = true;
    } else if(evt.keyCode == 32 && evt.type == "keyUp"){
      trace("Space released");
      stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
      stage.removeEventListener(KeyboardEvent.KEY_UP, keyDownHandler);
      menu.visible = false;

  • New SSD only boots when option key held down.

    I recently cloned the original HDD in my mid-2009 MBP [2,53] to a brand new SSD. I put the SSD in an external enclosure, formatted and then cloned.
    Then I put replaced the internal HDD with the SSD and put the HDD to rest in a drawer forever. If I hold down option upon startup, I'm able to choose the new SSD and launch. But if I just turn my MBP on, I simply get a white/grey screen.
    Not a giant problem, but not sure why it would not just boot normally. Is there some kind of step required to make the new SSD the default startup drive?
    Thank you.

    Shootist007 wrote:
    Also if this one one of these new iMacs that come with the bluetooth wireless keyboards that is also the problem. These BT keyboard are not recognized right away when the system turns on so it is a Hit & Miss type of thing getting any of the Boot Options to work correctly. If you press to soon it is not registered. If you pres to late the system has already bypassed the system to use the boot option keys. this is not only for the Option key press to bring up the Boot selection screen. it also doesn't work for the Recovery HD boot or the boot from DVD key and any other boot option keys.
    As far as I can tell the window in which you should press the key runs from the start (but not before) of the chime to before it ends (bit vague).

  • Mouseover/Mouseout Animation bug when mouse moved quickly/fast over it.

    Hi everyone, this is the first time I create a thread on adobe forum ^^
    In edge animate I made a pretty simple animation :
    - I made a square
    - I made a movieclip with an animation of about 200ms (opacity) that show some text appart from the square.
    Then I used mouseover/mouseout on the square to play & playReverse the animation of the text like that :
    Mouseover :
    sym.getSymbol("textclip").play();
    Mouseout :
    sym.getSymbol("textclip").playReverse();
    So everything works fine when I move the mouse on & off the square.
    I made this 6 times, so I have 6 differents square & 6 differents text animation.
    But when I quickly move the mouse from one to another, some animation just bug but in a strange way :
    the text is always shown and when I move the mouse to the associate cube that is normally playing the animation the text simply dissapear, and show back when I leave the cube with my mouse.
    I tried to use mouseenter mouseleave but I'm not really sure what to use and how to do that.
    Thanks in advance for any help.

    Hi, Achyp-
    Welcome to the forums!  As you mentioned, you should use mouseenter and mouseleave instead of mouseover and mouseout.  Here's what you would do:
    Delete your mouseover and mouseout events
    Add the mouseenter event and stick your code from mouseover into it
    Add the mouseleave event and stick your code from mouseout into it
    Hope that helps point you in the right direction!
    Thanks,
    -Elaine

  • Why can't I uninstall an app? My icons wiggle when button is held down but no X appears.

    I hold down the application button until they wiggle but an X never appears to allow me to select the apps that I want to delete.  How do I fix this? 

    do you have restrictions turned on? (Setting/General/Restrictions) - there is an option in Restrictions to turn off the ability to delete apps - the beahvior you are describing is exactly what would happen if that restriction is turned on

  • Clicking Causes mouse to be held down

    I've been having an odd glitch, sometimes when I click my mouse (I've tried with different mice) the mouse gets held down, and the only way to release it is to right click. This is especially bad trying to move files in Finder, as it means I can't let go of the file. Any resolutions?

    I'm assuming by the fact that you say you have tried different mice that the actual mouse is fine, it's just holding the click on the screen.
    First thing would be to check the Mouse settings under the System Preferences.
    JD

  • Jbutton: Button held down or clicked

    Hello. I am implementing an mp3 player in Java. I want to implement a button that behaves differently when it is held down and when it is just clicked. For example, when the button is held down,fast forward is called. When the button is just clicked, it goes to the next song in the playlist.
    I have tried to implement this with the mouse listeners mouseclicked, pressed and released but it is hard to get only one action happening at a time. My main question is how do you differentiate betwen a button being held down and a button just being clicked?
    here is a snippet of my non functional code:
    nextSongButton.addMouseListener(new MouseAdapter() {
    // go to next song
    public void mouseClicked(MouseEvent event) {
    System.out.println("entering mouseclicked");
    int m = event.getModifiers();
    System.out.println(event.getClickCount());
    if ((event.getClickCount() == 1) && ((m & InputEvent.BUTTON1_MASK) != 0 )) {
    mp3Playlist.playNextSong();
    updateFileInfo();
    // Do fast forward
    public void mousePressed(MouseEvent event) {
    System.out.println("entering mousepressed");
    if (fastForwardState.equals("OFF")) {
    mp3Playlist.fastForward();
    fastForwardState = "ON";
    // Go back to normal play
    public void mouseReleased(MouseEvent event) {
    System.out.println("entering mousereleased");
    mp3Playlist.normalPlayback();
    fastForwardState = "OFF";
    Any code sample similar to the above would be very helpfull. Maybe I can implement this with some kind of timer delay? It could trigger after the button is held down for half a second.
    Thank you very much for your help.

    The thought that first occurs to me is to use a thread. Start the thread in mousePressed and kill it in mouseReleased. The thread will wait 1 sec, then 'turn on' FF (unless it gets killed first). Also stop FF in mouseReleased.

  • Network traffic only happens when mouse cursor moving

    Network traffic only happens when mouse cursor is moving over Firefox window. It's even stopping me sending this message! Doesn't affect 32-bit XP machine.

    -> [[Troubleshooting extensions and themes]]
    -> Clear Cookies & Cache
    * https://support.mozilla.com/en-US/kb/Template:clearCookiesCache
    -> [[How to clear the cache#w_clear-the-cache|Clear the Network Cache]]
    -> Also try the suggestions mentioned in the following articles:
    * [[Firefox cannot load websites but other programs can]]
    * [[Firefox never finishes loading certainwebsites#w_lower-the-max-number-of-http-connections|Lower the max number of HTTP connections]]
    Check and tell if its working.

  • How to preven JButton of generated actions when the user keep pressing down

    How to preven JButton of generated actions when the user keep pressing down the key or the short cut
    The code below to show the issue when the user keep pressing Alt+ O
    We want to prevent the JButton from generating multi actions just one action only
    A sample of code shows the behaviour which has to be prevented. Continue pressing "Alt +O" and you will see the standard ouptput will print time stamps
    Please notice, I am NOT interested in Mouse press which has a solution by adding a threshold ( setMultiClickThreshhold(long threshhold) on the JButton  as an attribute.
    public class TestPanel extends JPanel
       private JButton btn;
       public TestPanel()
          btn = new JButton("Open");
          this.add(btn);
          registerCommand(new MyAction(), InputEvent.ALT_MASK,
                KeyEvent.VK_O, btn, btn.getText(), 0);
       public static void registerCommand(AbstractAction action,
             int mask,
             int shortCommand,
             JComponent component,
             String actionName,
             int mnemonicIndex)
          InputMap inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
          KeyStroke knappKombination = KeyStroke.getKeyStroke(shortCommand, mask);
          if ((component instanceof AbstractButton)
                && mnemonicIndex >= 0
                && mnemonicIndex < actionName.length()
                && (shortCommand >= KeyEvent.VK_A && shortCommand <= KeyEvent.VK_Z))
             ((AbstractButton) component).setDisplayedMnemonicIndex(mnemonicIndex);
          if (inputMap != null)
             ActionMap actionMap = component.getActionMap();
             inputMap.put(knappKombination, actionName);
             if (actionMap != null)
                actionMap.put(actionName, action);
       public static class MyAction extends AbstractAction
          private static final long serialVersionUID = 1L;
          @Override
          public void actionPerformed(ActionEvent e)
             System.out.println(System.currentTimeMillis());
       public static void main(String... args)
          SwingUtilities.invokeLater(new Runnable()
             public void run()
                JFrame frame = new JFrame("Testing");
                JPanel panel = new TestPanel();
                frame.getContentPane().add(panel);
                frame.setPreferredSize(new Dimension(500, 500));
                frame.setMinimumSize(new Dimension(500, 500));
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
    }Edited by: user12130673 on 2013-feb-13 03:01

    Use KeyStroke getKeyStroke(int keyCode, int modifiers, boolean onKeyRelease) with onKeyRelease=true instead?

  • Machine mistakenly thinks mouse button is held down while dragging

    I have a bizarre, intermittent problem. Very occasionally, when I'm dragging files between folders, my computer thinks that the mouse button is still being held down even after I release it. As a result, I am constantly "carrying" the files around the screen with the mouse and I'm completely incapable of doing anything else since the machine thinks I'm mid-drag. As far as I can figure out, the only way to fix this is to reboot the machine. Extreme, I know, but I can't figure out any other way to get out of this state. This typically happens to me once or twice a week and I use my computer fairly heavily.
    So, has anyone else heard reports of this bizarre behavior before? Any solutions?
    I don't know if this matters, but I'm using a wireless mouse. However, plugging in a wired mouse while this is happening doesn't seem to be a solution.

    Have you checked your System Preferences? If not...
    Open System Preferences from your Application folder. Click: Keyboard&Mouse, and select the Mouse tab. At the bottom of that window change your Tracking, Scrolling and double clicking to see if that makes a difference.
    If the wireless is a Mighty Mouse, try cleaning it: http://support.apple.com/kb/HT1537
    Mice need cleaning periodically. Fingerprints, lotions, dust, and lint can cause problems.
    Clean the USB mouse as well.
    Carolyn

  • Mighty Mouse can't Scroll DOWN over Ads

    Does anyone else have this issue?
    Safari Beta (3.0.3), 10.4.10, USB mighty mouse.
    When I go to some pages, say this one:
    http://gamers-creed.com/?p=230.
    And scroll down over the ads, the scrolling stops. Scrolling up is fine. It's annoying because it fees like it's intentionally trying to get me to stop and read an ad.
    I've narrowed it down to javascript, (off everything is fine) and possibly iFrames. Does anyone have any info, or know of a way to retain full scrollability (is that a word?) and keep evil javascript on?
    Thanks!

    Hi
    I've noticed the same with both my iMac Mighty Mouse, and iBook Logitech Mouse. Both machines are using 3.0.3. This has been happening with Beta 3 from the get-go.
    I've sent a bug report to Apple via the Safari Menu>Report Bugs to Apple.

  • Has anybody had a problem with the mouse cursor lagging when navigating the drop down menus? this only started happening after a re-install. it only occurs in Photoshop elements 13 in the  photo editing section,and no other application. My mouse drivers a

    Has anybody had a problem with the mouse cursor lagging when navigating the drop down menus? this only started happening after a re-install. it only occurs in Photoshop elements 13 in the  photo editing section,and no other application. My mouse drivers are up to date.Any help or advice would be most welcome.

    Good day!
    Please post Photoshop Elements related queries over at
    http://forums.adobe.com/community/photoshop_elements
    and please read this (in particular the section titled "Supply pertinent information for quicker answers"):
    http://blogs.adobe.com/crawlspace/2012/07/photoshop-basic-troubleshooting-steps-to-fix-mos t-issues.html
    Regards,
    Pfaffenbichler

Maybe you are looking for

  • Windows Vista and Nokia PC Suite

    Hi I have a problem with compatibility of nokia pc suite , it doesnt work on Windows Vista , and i have to install some apps to my phone through usb cabel because i havent bluetooth card in my pc ( Is it any version for Windows Vista ? I didnt find i

  • Windows 8.1 Not Seeing Ubuntu Server

    I have been running a file server with Ubuntu Server 14.04.1 as the OS and Samba 4.1.6 to share the files. I was able to connect to the server and access all of its drives from both my desktop and laptop running Windows 7. I upgraded my laptop to Win

  • Can I use Airport TimeCapsule's internal hard drive as a network-based backup solution for both windows and mac?

    Does the following scenario work??? :- A Windows PC is connected to Airport TimeCapsule (ATC) wifi. A Mac is connected to the ATC wifi. The Mac's Time Machine software is set up and automatically backs up to the internal HDD. The Mac can browse files

  • Why does my iPhone 4 keep restarting

    My iPhone 4 keeps turning on and off, I bought it two days ago second hand and the back of the phone was cracked, this I have had replaced and the store owner updated the phone but it still keeps doing the same thing, Any ideas ???

  • Video Clip from my camera

    Can I download a little video clip that I took with my digital camera to my ipod? And if so, how do I do that? Thank you for the help. Dell Dimension   Windows XP