Transparent parts of component are preventing mouse events

Hello,
I am working with a bunch of components that are layered over top of eachother.
Some of the components are odd shaped and have a transparent background.
When I try to click on components that are behind others the mouse event is not fireing.
is ther a way I can fix this?
Drew

There is a difference between transparent background and no background.  If I take a Sprite and draw a filled triangle like this:
moveTo(0,0)
lineTo(100, 100)
lineTo(100, 0)
lineTo(0,0)
Then any component under the half I didn't draw on is "visible" to the mouse and my Sprite will not get mouse events.
If I fill that area with a background with alpha=0, then I've effectively placed a piece of glass in my component and it will get mouse events even though you can see through to things behind it.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui

Similar Messages

  • Using activex component in openGL app:  mouse event issues.....

    i'm trying to get the Flash ActiveX control to work in an
    OpenGL app. so far i've managed to get the bitmap data and map it
    to a texture succesfully. but i'm having problems getting the mouse
    interaction to work.
    i get an hWnd from IShockWaveFlash's IOleWindow. when i send
    mouse messages to it, the mouse is interpreted correctly by
    actionscript (for example, i have a custom mouse cursor tracking
    _xmouse, _ymouse which works fine).
    however, buttons do not behave correctly. rollover is
    erratic, and only in rare circumstances can i get a button's
    onPress handler to fire.
    am i sending the mouse events in correctly? any ideas of any
    other way to send them in?

    Thank you for you mail,
    After I read this article
    http://digital.ni.com/public.nsf/3efedde4322fef198​62567740067f3cc/610540bb3ea4ebdd862568960055e498?O​penDocument
    I realized that ActiveX events are not supported on CVI 5.01 at all since
    its introduced as a new feature of CVI 5.5
    "Azucena" wrote:
    >Daniel,>>Have you tried the function CA_RegisterEventCallback function?
    (I am using>CVI 5.5)>>This function is used by the functions generated by
    the Automation>Controller Instrument Driver Wizard.>It is not intended to
    be used directly.>>It basically registers a callback for an ActiveX Automation
    server object>event.>To register the callback, you must specify the CAObjHandle
    of the server>object from which you want to receive events.>>W
    ith CVI 5.5,
    there is an example for IE with Active X under the>samples/activeX directory.>>Hope
    this helps,>>Azucena>>"Daniel Bentolila" wrote in message>news:[email protected]..>>>>
    Has anybody tried to capture an ActiveX component event in a CVI>application>>
    ?>>>> for example I've created a new instance of the Internet Explorer>application>>
    from the CVI , using the ActiveX Automation controler I choosed the>Microsoft>>
    internet controls then I selected IWebBrowser2 and the IWebBrowserEvents2>>
    classes and generated the fp file for the CVI.>> Under the the IWebBrowserEvents2
    I see there are events fucntion for>example>> OnQuit, and I wanted my CVI
    app. to attach the quit event when the user>closes>> the IE window.>> Now
    at this point I expected to find some mechanism that let me to install>>
    some callback function where I can put my customised code to the quit>event,>>
    somehow I have to tell the IE to call my function whenever the OnQuit>callback>>
    fun
    ction is attached and I don't know how to do this.>>

  • Having picked up a mouse event, pass it to parent component.

    This is further to my table cell hover, which is otherwise working.
    I track the mouse accross the table using an invisible child component, and when the mouse leaves it, move the child onto the new cell position.
    The problem is that, while the mouse is over the invisible component, that component is grabbing all the mouse events. My table also wants to detect mouse events (though it's interested in clicks).
    The obvious thing is, after they've been dealt with and the child component level, to transfer the events to the table (having mapped the mouse coordinates). However all the processEvents methods in components like JTable are protected.
    I suppose I could extend JTable and add a method to get arround protected, but that's nasty, especially since a lot of my JTables are already subclassed.

    I had to do just this. I have JLabel's in a JPanel. The JPanel is in a LayeredPane. When I mouse over the JLabels, they grab the mouse events... which I don't want. I want the LayeredPane to get it.
    So in the JLabel, I do:
          * Don't send to parent what you don't have to. Things like tooltips will
          * be broken if this is not handled carefully...
         public void mouseClicked(MouseEvent e) { }
         public void mouseMoved(MouseEvent e) { }
         public void mouseEntered(MouseEvent e) { }
         public void mouseExited(MouseEvent e) { }
         public void mouseReleased(MouseEvent e) { machine.dispatchToParent(e);}
         public void mouseDragged(MouseEvent e) { machine.dispatchToParent(e);}
         public void mousePressed(MouseEvent e) { machine.dispatchToParent(e);}(the "machine" above is a JPanel). Now in the JPanel, aka "machine", I do:
    Point point; int comp_x, comp_y; // for component with respect to this machine
    public void dispatchToParent(MouseEvent e) {
         point=((JComponent)e.getSource()).getLocation();
         //System.out.println("Dispatching: " + e.getX() + " " + e.getY());
         //System.out.println("Component position: " + ((JComponent)(e.getSource())).getLocation());
         if (e.getButton() > 0) MsgIFrame.println("ME at: " + comp_x + "," + comp_y + " button: " + e.getButton() );
         if (e.getButton() > 1) {
              popup(e);
              return;
         comp_x=(int)point.getX(); comp_y=(int)point.getY();
         comp_x+=this.getX(); comp_y+=this.getY();
         e.translatePoint(comp_x, comp_y);
         room.getLayeredPane().dispatchEvent(e);
    }Above, the "room" is a JInternalFrame with a LayeredPane inside it, as you can see. I do a little translating so the LayeredPane gets the event in its coordinate space, not those of its Components.

  • Mouse Events are slow

    Hello everyone,
    I'm currently working on an standard as3 (1024x768) app that
    is running inside a chromeless Air window to take advantage of the
    transparency.
    All my tests where done using windows XP professional and AIR
    1.0 (the same problem existed in beta3).
    The issue I'm having is related with Mouse Events. Somehow
    the events take a lot of time to reach the swf file when the user
    clicks inside the transparent window.
    It's natural that the app runs slower inside a transparent
    window (the framerate drops) but I wasn't expecting the clicks to
    suffer from such delay (it takes sometimes 2-5sec).
    The app is very CPU intensive and the transparencies make it
    worse. Something inside the AIR framework is not dispatching the
    events properly.
    I say this because I tried using the virtualMouse class from
    senocular together with a socket to simulate the mouse clicks and
    that did the trick.
    In conclusion:
    Something in the AIR framework for windows XP is messing up
    the dispatch of the Mouse events when the app is under heavy cpu
    usage inside a chromeless window. I click on the window and it
    takes 1-2sec to receive the click event.
    However when I dispatch the MouseEvent.CLICK myself using
    the virtual mouse class the application immediately receives the
    event.
    I know this is a strange bug and not many people will have
    this problem, but I would like to know from someone with knowledge
    of the runtime why this could be happening.
    Thank you
    Tiago Bilou

    Hello everyone,
    I'm currently working on an standard as3 (1024x768) app that
    is running inside a chromeless Air window to take advantage of the
    transparency.
    All my tests where done using windows XP professional and AIR
    1.0 (the same problem existed in beta3).
    The issue I'm having is related with Mouse Events. Somehow
    the events take a lot of time to reach the swf file when the user
    clicks inside the transparent window.
    It's natural that the app runs slower inside a transparent
    window (the framerate drops) but I wasn't expecting the clicks to
    suffer from such delay (it takes sometimes 2-5sec).
    The app is very CPU intensive and the transparencies make it
    worse. Something inside the AIR framework is not dispatching the
    events properly.
    I say this because I tried using the virtualMouse class from
    senocular together with a socket to simulate the mouse clicks and
    that did the trick.
    In conclusion:
    Something in the AIR framework for windows XP is messing up
    the dispatch of the Mouse events when the app is under heavy cpu
    usage inside a chromeless window. I click on the window and it
    takes 1-2sec to receive the click event.
    However when I dispatch the MouseEvent.CLICK myself using
    the virtual mouse class the application immediately receives the
    event.
    I know this is a strange bug and not many people will have
    this problem, but I would like to know from someone with knowledge
    of the runtime why this could be happening.
    Thank you
    Tiago Bilou

  • Why are transparent parts of ID file turning to gray in PDF?

    The transparent parts of my InDesign files are going to gray boxes (x-ray looking) around them.  I have done hundreds, if not thousands of PDF's from ID without an issue and all of a sudden this is happening. Though I have already figured out and used a jpeg work-around for now, I am still searching for the answer as to WHY this is happening all of a sudden, without any updates or changes on my end. WHY??? Can anyone else can shed a light on this?  Thanks.

    I guess the question is, has a recent automatic update in Adobe software (this happens in Illustrator CS5.5, too) created a change in how PDF's are processed through their software?  Nothing I have done is different or has been reset...have used all of the software since it's creation, so I'm not a novice whatsoever.  It appears that any shape that is created using the transparency/gradient feature in the software turns to gray in the PDF's when using the save as PDF internal software feature in every configuration (then opens in Acrobat Pro...not Apple Preview, which has it's issues).  This has nothing to do with jpegs or anything else that is placed in the file (my reference to jpegs in my question is how I wound up saving the original file so everything would be flattened).  This work around is not a solution for me.b I am trying to find out if I am stuck with this because of Adobe software updates or something changed recently.  I am not the only person that has posted this issue on the web, but wanted to go straight to Adobe experts to see if anyone could shed any light on it.  Thanks for your time.

  • Event case missing mouse events on active-x component

    I am using a Treeview and capturing selections in the tree using mouse events (event structure). I have a problem where approx 3 out of 15 mouse events are not actioned by the event structure - has anyone else had this problem or is there any suggestions?
    Thanks.

    Could you post a copy of your code that demonstates this?
    I have experimented with this control and its events.
    We may be able to help if we have soething to look at.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • All buttons in all files are now showing error: Mouse events are permitted only for button instances.

    Somebody please help:
    I've taught myself enough with Flash to customize a
    fully-Flash template for my wife's website, and two of the buttons
    didn't do what I wanted them to in Actionscript. They then began
    giving me the message:
    **Error** Symbol=sub_butt1, layer=Layer 4, frame=1:Line 1:
    Mouse events are permitted only for button instances
    on (rollOver) {
    **Error** Symbol=sub_butt1, layer=Layer 4, frame=1:Line 4:
    Mouse events are permitted only for button instances
    on (releaseOutside, rollOut) {
    Total ActionScript Errors: 2 Reported Errors: 2
    Not only do I not know how to fix this, the same message
    comes up for every single button in the entire fla I had saved,
    plus earlier versions where I hadn't even messed with the buttons
    yet.
    Any suggestions?

    Hello Corbett,
    The error is saying that you are trying to apply a button
    action to something
    other than a button. Often this happens when you select the
    frame that the
    button is on instead of the actual button, thus applying the
    action to the
    frame instead of the button.
    Make sure you select the button on the stage and then apply
    the actions there.
    You'll probably have to remove the action from the frame
    before it will work
    (looks like it's on Layer 4 frame 1).
    Good luck!
    Jesse H.
    Adobe Community Expert
    My site:
    http://www.jharding.com
    Free Blog Radio:
    http://www.tornadostream.com
    > Somebody please help:
    > I've taught myself enough with Flash to customize a
    fully-Flash
    > template for
    > my wife's website, and two of the buttons didn't do what
    I wanted them
    > to in
    > Actionscript. They then began giving me the message:
    >
    > **Error** Symbol=sub_butt1, layer=Layer 4, frame=1:Line
    1: Mouse
    > events are
    > permitted only for button instances
    > on (rollOver) {
    > **Error** Symbol=sub_butt1, layer=Layer 4, frame=1:Line
    4: Mouse
    > events are
    > permitted only for button instances
    > on (releaseOutside, rollOut) {
    > Total ActionScript Errors: 2 Reported Errors: 2
    >
    > Not only do I not know how to fix this, the same message
    comes up for
    > every
    > single button in the entire fla I had saved, plus
    earlier versions
    > where I
    > hadn't even messed with the buttons yet.
    > Any suggestions?

  • Get all mouse events no matter what component the mouse is over

    Is there anyway to get all the mouse events, in for example, an applet? Usually, the only component that recieves the mouse event is the component which is being hoverred by the mouse. Is there anyway to just get all the mouse events without adding listeners to every component?
    Problem:
    Well, the real problem is that I have an Applet, that the componentCount() method returns 0. I want to get all mouse events on the applet, but if I just do a appletInstance.addMouseListener(this), it doesn't recieve the mouse clicks. It does however, get mouse exit and mouse enter events.
    Thanks for any support.

    Use an AWTEventListener:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=727731&start=1

  • How Keyboard & Mouse Events are handled in java?

    Hi
    How Keyboard & Mouse Events are handled in java?
    Kindly brief, how a key typed in the keyboard is sensed and it is entered in JTextField?
    or
    Pls. give me some links.
    Am going to send the events from external device (like keyboard) to OS and from that I need to capture that event in Java Swing?
    Pls. drop in a bit. So that it will be helpfull to me.
    Thanks in advance,
    bee

    Actualy am very much aware of using KeyListener and MouseListener. I am in need of internal details,
    how typing a key in keyboard is captured by KeyListener? How the event is passed to java swing and and it is fired to keylistener.
    Pls. help me.
    Thanks
    bee

  • JPanels are not reading Mouse Events

    I created a basic Tic Tac Toe game, with individual "TicPanel"s inside a JPanel inside a JFrame object, however, none of the mouse events are working? Is it because the JFrame is receiving and doing nothing with the MouseEvents?
        private class TicPanel extends JPanel implements MouseListener
            private int owner; //-1 = none, 0 = O, 1 = X
            private Graphics g;
            private int num;
            ActionListener listener;
             * Constructor
            public TicPanel(int num)
                this.num = num;
                g = getGraphics();
                owner = -1;
            public void setX()
                owner = 1;
                g.drawLine(0,0,getWidth(),getHeight());
            public void setO()
                owner = 0;
                g.drawOval(0,0,getWidth(),getHeight());
            public int getOwner()
                return owner;
            public void mousePressed(MouseEvent evt){}
            public void mouseReleased(MouseEvent evt){}
            public void mouseExited(MouseEvent evt){}
            public void mouseEntered(MouseEvent evt){}
            public void mouseClicked(MouseEvent evt)
                System.out.println("works");
                listener.actionPerformed(new ActionEvent(this, num, ""));
                setX();
            public void addActionListener(ActionListener listener)
                this.listener = listener;
        }   Edited by: TheWhiteLynx on Aug 10, 2009 2:16 PM

    TheWhiteLynx wrote:
    I created a basic Tic Tac Toe game, with individual "TicPanel"s inside a JPanel inside a JFrame object, however, none of the mouse events are working? Is it because the JFrame is receiving and doing nothing with the MouseEvents?I don't see anywhere that you are adding a MouseListener to anything. Usually this is done with the addMouseListener(...) method.
    Oh, and please read the Sun graphics tutorial as this is not the way to do graphics in Swing. You do not want to get the Graphics object via getGraphics method but instead do your painting in a paintComponent override method and get your Graphics object from the parameter passed to this method. The tutorials will explain all.
    Edited by: Encephalopathic on Aug 10, 2009 2:29 PM

  • Are there any events to script a component when dragged and dropped into the parsys area?

    are there any events to script a component when dragged and dropped into the parsys area?

    The cq:listeners node of a component's cq:EditConfig has a number of events that fire with relation to the edit mode drag'n'drop stuff. You would probably want to hook one or more of the insert ones (beforeinsert, beforechildinsert, afterinsert, afterchildinsert).

  • How to throw the mouse event to a upper level component?

    For example: a panel using absolute layout, and there is a label on it.
    Now when mouse clicked on the label, i do not want the label but the panel to get the mouse event , so that i can get the mouse click point's x and y in the panel.
    How to implement it?
    Thanks a looooooooooooot for ur help
    Best Regards

    try this
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class Testing extends JFrame
      public Testing()
        setSize(100,75);
        setLocation(300,200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        final JPanel p = new JPanel();
        JLabel lbl = new JLabel("Click Me");
        lbl.setToolTipText("OK");
        lbl.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        p.add(lbl);
        getContentPane().add(p);
        lbl.addMouseListener(new MouseAdapter(){
          public void mousePressed(MouseEvent me){//match method name
            p.dispatchEvent(me);}});
        p.addMouseListener(new MouseAdapter(){
          public void mousePressed(MouseEvent me){//with this method name
            System.out.println("Panel clicked");}});
      public static void main(String[] args){new Testing().setVisible(true);}
    }

  • When both plug-in objects and jQuery mouse events are present, Firefox re-starts the plug-in object (eg Flash movie) after a jQuery mouse event occurs. This doesn't happen in any other browser. How can I get around this?

    Please check http://www.syus.com for an example. There is a Flash movie underneath the main navigation. The main navigation has a jQuery mouse event, and when you mouse over a button in the main navigation, the Flash movie re-starts. I can confirm that this happens not only on Flash swf files, but on standard <object> YouTube embeds.

    Ok, I promise this is my last post without your help. I did some more troubleshooting and it only seems to happen when jQuery appends elements to the body that were previously invisible. In other words, I can simply change the css in jQuery from using element.css('display','inline'), but if I try to use something like slideDown or other jQuery tooltip functions that append and/or remove elements or style definitions it causes the "object restart" bug.
    It is impossible for any developer to eliminate this bug without changing the actual source of jQuery, which I can't do. My only other option is not to use sophisticated show/hide jQuery elements like drop-down menus and tooltips on the same page as an embedded object, but I don't want to do this since Safari, Chrome and even IE (dear God) users won't have a problem with this. I think this is a major major bug that should be fixed in Firefox 4 as more and more sites will be looking to use the latest jQuery plugins.

  • How can I make only the shape active for the mouse events, not the whole box around it?

    I want to create mouse over events for different parts of an image (say of a hard disk drive), so when the user places their mouse over the spindle, say, it will change colour.
    At the moment I have it working however the event is triggered when ever the mouse is in the bounding box of the spindle image. How can I get it to only be triggered when it is above the non transparent part of the image (or symbol)?

    Thanks joris182, but that wont work when there are other objects within the bounding box of the transparent symbol. For example, if I want the sclera to highlight, if I use an invisible shape over it, it will be active even if someone has their mouse over the vitreous body.

  • Getting clipped graphics when painting in response to mouse event

    Can anyone tell me how to get a graphics object with the clipping region set appropriately when painting in response to a mouse action
    rather than in paintComponent where the system provides the Graphics object?
    The issue is that a graphical component I have written needs to repaint parts of itself in response to mouse actions. I have been getting the Graphics object by calling getGraphics on the component (based on JPanel) and using that to do the required painting. This works fine as long as there are no lightweight Swing objects in front of my component, but as I recently discovered when I added this component to a couple of JInternalFrames, mouse-triggered painting can paint on the other JInternalFrame.
    The example code below illustrates the problem.
    Thanks in advance
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.Ellipse2D;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    * This class illustrates a problem I am having with a graphical component I have
    * written that works fine when placed in a JFrame, but when placed inside a JInternalFrame,
    * can draw outside the bounds of the JInternalFrame.
    * The real component contains many sub-objects, and users can select an individual sub-object,
    * and trigger actions specific to that sub-object. To aid in sub-object selection,
    * when the mouse pointer is over a sub-object, the color of the object is changed to
    * a highlight color. This is where the problem of drawing outside the JInternalFrame occurs.
    * I am pretty sure that the reason the drawing can occur outside the bounds of the
    * JInternalFrame is that the graphics context used for the highlighting action does not
    * have the clipping region set. Unlike in paintComponent where the system provides the
    * Graphics object with the clipping region set appropriately, painting of individual
    * sub-objects in response to a MouseEvent is done using a call to getGraphics on the
    * component. This has the clipping region set to the dimensions of the JPanel.
    * This example creates two overlapping JInternalFrames. Inside each is a simple component
    * based on a JPanel. The component draws a single filled circle which corresponds to
    * one of the sub-objects in the real component. When the mouse pointer is over a circle,
    * the color changes from gray to red. Where the circle overlaps the other JInternalFrame,
    * the circle will paint over that frame.
    public class GraphicsProblemDemo extends JFrame {
        private static final int APP_FRAME_SIZE = 400;
        public GraphicsProblemDemo()
            JDesktopPane desktop = new JDesktopPane();
            setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            getContentPane().setLayout( new BorderLayout() );
            getContentPane().add( desktop, BorderLayout.CENTER );
            setSize( APP_FRAME_SIZE, APP_FRAME_SIZE );
            setVisible( true );
            // Create two JInternalFrames, each with a single component that
            // draws a filled circle.
            JInternalFrame frame = createInternalFrame( 0, 0 );
            frame.setVisible( true );
            desktop.add( frame );
            frame = createInternalFrame( 200, 200 );
            frame.setVisible( true );
            desktop.add( frame );
        public JInternalFrame createInternalFrame( int left, int top )
            JInternalFrame frame = new JInternalFrame( "", true, true, true, true );
            int INTERNAL_FRAME_SIZE = 300;
            frame.setBounds( left, top, INTERNAL_FRAME_SIZE, INTERNAL_FRAME_SIZE );
            myComponent shape = new myComponent();
            frame.add( shape );
            return frame;
         * This component simulates the more complex component that I am trying to debug.
         * The real component contains many sub-objects and is expensive to render.
         * Individual sub-objects are selectable within the component, and to indicate to the
         * user that the mouse is positioned over a sub-object, the sub-object color is changed.
         * Because it is expensive to render the component completely, the MouseMotionListener
         * does not call repaint on the component. Instead, it gets the graphics context,
         * sets the color, and renders the component under the mouse pointer.
        class myComponent extends JPanel implements MouseMotionListener {
            private Ellipse2D.Double subObject = new Ellipse2D.Double( 10, 10, 200, 200 );
            private Color unselectedColor = Color.LIGHT_GRAY;
            private Color selectedColor = Color.RED;
            private Color renderColor = unselectedColor;
            public myComponent()
                addMouseMotionListener(this);
            // Painting is fine when this method is called by the system.
            public void paintComponent( Graphics g )
                super.paintComponent( g );
                // In the real component, many objects would be rendered here, but
                // this example component has only a single sub-object.
                renderMySingleSubObject( g );
            // But when this method is called by my mouse listener using the
            // graphics context from the containing JPanel, the circle is rendered on top
            // of the other JInternalFrame.
            private void renderMySingleSubObject( Graphics g )
                Graphics2D g2d = (Graphics2D) g;
                g2d.setColor( renderColor );
                g2d.fill( subObject );
             * If the mouse pointer is over my single sub-object, then change
             * the color from gray to red and render  the sub-object.
             * @param e The MouseEvent
            public void mouseMoved( MouseEvent e )
                if( subObject.contains( e.getX(), e.getY() ) )
                    renderColor = selectedColor;
                else
                    renderColor = unselectedColor;
                Graphics g = myComponent.this.getGraphics();
                // This graphics context does not have the clipping region set
                renderMySingleSubObject( g );
            public void mouseDragged( MouseEvent e )
        public static void main( String[] args )
            new GraphicsProblemDemo();
    }

    Checking the method description for the 'getGraphics' method in the Component api the first sentence says "Creates a graphics context for this component." Emphasize 'creates'. You can demonstrate the difference by printing the Graphics context g in each case. Checking for the clip in each returns null for the 'getGraphics' call.
                super.paintComponent( g );
                // In the real component, many objects would be rendered here, but
                // this example component has only a single sub-object.
                renderMySingleSubObject( g );
                System.out.println("paintComponent g = " + g);
                System.out.println("paintComponent g clip = " + g.getClip().toString());
                Graphics g = myComponent.this.getGraphics();
                System.out.println("getGraphics g = " + g);
                // NullPointer here...
                System.out.println("getGraphics g clip = " + g.getClip().toString());Suggests that 'getGraphics' might not be the way. You could, of course, check all the iframes and find out how much of the moused-over ellipse is visible and put together something to send along for the re-rendering...
    Here's another possibility. The repaint code doesn't recover well for mouse exits of the lower iframe into the upper but it will give an idea about economy and control.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.geom.Ellipse2D;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseMotionListener;
    public class GPD extends JFrame {
        private static final int APP_FRAME_SIZE = 400;
        public GPD()
            JDesktopPane desktop = new JDesktopPane();
            setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            getContentPane().setLayout( new BorderLayout() );
            getContentPane().add( desktop, BorderLayout.CENTER );
            setSize( APP_FRAME_SIZE, APP_FRAME_SIZE );
            setVisible( true );
            // Create two JInternalFrames, each with a single component that
            // draws a filled circle.
            JInternalFrame frame = createInternalFrame( 0, 0 );
            frame.setVisible( true );
            desktop.add( frame );
            frame = createInternalFrame( 200, 200 );
            frame.setVisible( true );
            desktop.add( frame );
        public JInternalFrame createInternalFrame( int left, int top )
            JInternalFrame frame = new JInternalFrame( "", true, true, true, true );
            int INTERNAL_FRAME_SIZE = 300;
            frame.setBounds( left, top, INTERNAL_FRAME_SIZE, INTERNAL_FRAME_SIZE );
            myComponent shape = new myComponent();
            frame.add( shape );
            return frame;
        class myComponent extends JPanel implements MouseMotionListener {
            private Ellipse2D.Double subObject = new Ellipse2D.Double( 10, 10, 200, 200 );
            private Color unselectedColor = Color.LIGHT_GRAY;
            private Color selectedColor = Color.RED;
            private Color renderColor = unselectedColor;
            int count = 0;
            public myComponent()
                addMouseMotionListener(this);
            // Painting is fine when this method is called by the system.
            public void paintComponent( Graphics g )
                super.paintComponent( g );
                g.setColor( renderColor );
                ((Graphics2D)g).fill( subObject );
             * If the mouse pointer is over my single sub-object, then change
             * the color from gray to red and render  the sub-object.
             * @param e The MouseEvent
            public void mouseMoved( MouseEvent e )
                boolean colorHasChanged = false;
                if( subObject.contains( e.getX(), e.getY() ) )
                    if( renderColor == unselectedColor )
                        renderColor = selectedColor;
                        colorHasChanged = true;
                else if( renderColor == selectedColor )
                    renderColor = unselectedColor;
                    colorHasChanged = true;
                if( colorHasChanged )
                    System.out.println("repainting " + count++);
                    repaint();
            public void mouseDragged(MouseEvent e) { }
        public static void main( String[] args )
            new GPD();
    }

Maybe you are looking for

  • Unable to see shared library

    I searched for and read about a dozen previous posts on this subject but was unable to find a solution. Not only can I not see any shared library but I don't even have a "shared" menu item on either PC as described in the help file. It should show up

  • Cant burn a song playlist off itunes because of error 4450 please help!!!

    Im trying to burn the new halifax cd onto a cd and it stops at no particular song and in different places and I have tried burning it anbout 4 times and it keeps getting cancedelled because error 4450 occurs What do i do!!!???

  • Lightroom 3.6 Problems by press Printing buttom

    Everytime i try to use the print funktion my Program shuts down. Thre days ago everything went fine. I do not understand, what happend.

  • Convert one record row into multiple rows

    Hi,    I have small requirement.I have selected one data base record into an internal table.Now internal table has 1 record i.e 1 row(ex: 10 columns). Now i will convert this single row record into multiple  records i.e 10 rows( 10 columns wil; be co

  • Two Macbooks, same spec, yet one has major connectivity issues

    Hi, I have two (old - 2006) macbooks, bought at exactly the same time, exactly the same spec, probably off the same factory line. Yet one has serious Airport issues which are proving very difficult. It will pick up a maximum of one wireless network,