Detecting a mouse click on any (all) child components...

Hey All,
I am writing a number of compound GUI elements that i want to make focusable when you click any part of them. (i.e. a JTextArea inside a JScrollPane, coupled to a JTextField to provide input to the JTextArea).
Is there an easy way to detect mouse clicks on child components of a JPanel?
My current code is:
m_oInputBox.addMouseListener(this);
m_oOutputBox.addMouseListener(this);
m_oScrollPane.getVerticalScrollBar().addMouseListener(this);
This detects most of the mouse clicks, but not those on the buttons that form the scroll bar ends or the scroll bar slider when it is present.
Any way tou can detect clicks on these too??
Iso

P.S. It does actually detect clicks on the scroll bar slider - just not onthe buttons that form the slider end caps (up/down).
Iso

Similar Messages

  • Detecting missing mouse clicks?

    There are some times when a user clicks on a movie clip in my
    SWF that the mouse click goes undetected by any of my mouse event
    handlers.
    I even added a MouseClick listener at the root sprite of my
    SWF.
    Is there any way to detect where this mouse click is going,
    and why it is not being detected by anything?
    NOTE: I have *only* seen this happen so far when a user
    clicks on a movie clip that I have dynamically loaded. The movie
    clip is not playing, and I am manually calling gotoAndStop() on the
    movie clip various times. Not sure if that is related.

    please don't cross post.

  • TreeSelectionListener detect if mouse click

    hi,
    i've got a JTree and I'm using a TreeSelectionListener to carry out different actions when the user clicks on nodes. however, sometimes i want to change the selection on the tree programmatically (i know how to do this bit), and for the action associated with clicking on the node not to happen.
    is it possible within the valueChanged method of the TreeSelectionListener to determine if the selection was changed by a mouse click or programmatically? or can anyone think of another way to approach this?
    cheers for any help!

    You can't do that with the event, but if you create a boolean variable named for example
    boolean programSelection = false;
    and when you change the selection programmatically you put the value to true. In the method valueChanged you have to test the value of programSelection like that :
    public void valueChanged(ChangeEvent e) {
       if (programSelection) {
          // the code when the selection come from the program
         programSelection = false;
       else {
          // the code when the selection come from the user
    }

  • Detecting change of position and size of child components

    As a JavafX learning excercise I want to create a scrollable container (Scrollbox). This may not seem a difficult thing to do but I want to simulate the CSS "overflow: auto" behaviour so the scrollbars only appear when the content overflows the container.
    With the following code I can detect when the content changes and determine if scrollbars are needed, but if any of the child components are moved or resized I need to call checkOverflow again and I can't figure out the binding to do this.
    override var content on replace {
    checkOverflow();
    I may have the approach completely wrong so any help is much appreciated.
    Thanks.
    coolbeans

    This is what I have ended up with. The container will dynamically add vertical and horizontal scrollbars if any nodes in the content overflow the scrollbox container. I have also added an option to allow the scrollbox area to be scrolled by dragging the content area but if you don't like this you can turn it off. The source code is below and as this is my first look at Javafx I will be interested in any feedback.
    * ScrollBox.fx
    * Copyright 2009 Coolbeans
    package coolbeans;
    import javafx.scene.CustomNode;
    import javafx.scene.Node;
    import javafx.scene.Group;
    import javafx.scene.layout.Panel;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.paint.Color;
    import javafx.scene.control.ScrollBar;
    import javafx.scene.input.MouseEvent;
    public class ScrollBox extends CustomNode {
    //Public Properties
    public var width: Number = 300 on replace { checkControls(); };
    public var height: Number = 300 on replace { checkControls();}
    public var content:Node[];
    public var borderColor:Color = Color.LIGHTGRAY;
    public var fill:Color = Color.WHITE;
    public var allowDragScroll:Boolean = true;
    //Private Stuff
    var view: Panel;
    var saveVscrollVal: Float;
    var saveHscrollVal: Float;
    var hscroll:ScrollBar = ScrollBar {
    vertical: false;
    visible: false;
    min: 0;
    var vscroll:ScrollBar = ScrollBar {
    vertical: true;
    visible: false;
    min: 0;
    override public function create() : Node {
    Group {
    content: [
    Rectangle {
    fill: bind fill
    width: bind width - 1
    height: bind height - 1
    stroke: bind borderColor
    hscroll, vscroll,
    Group {
    content: [
    view = Panel {
    content: bind content;
    onLayout: function() : Void {
    checkControls();
    layoutX: bind -hscroll.value
    layoutY: bind -vscroll.value
    clip: Rectangle {
    width: bind if (vscroll.visible) then
    width - vscroll.width
    else width;
    height: bind if (hscroll.visible) then
    height - hscroll.height
    else height;
    onMousePressed: function( e: MouseEvent ):Void {
    saveVscrollVal = vscroll.value;
    saveHscrollVal = hscroll.value;
    onMouseDragged: function( e: MouseEvent ):Void {
    handleMouseDrag(e.dragX, e.dragY);
    clip: Rectangle { width: bind width, height: bind height}
    function checkControls() : Void {
    var maxX:Float = 0;
    var maxY:Float = 0;
    //Calculate the maximum size of the viewport
    for (c in content) {
    var b = c.boundsInLocal;
    if (b.maxX > maxX) maxX = b.maxX;
    if (b.maxY > maxY) maxY = b.maxY;
    if (maxX > width) {
    hscroll.width = width;
    hscroll.layoutY = height - hscroll.height - 1;
    hscroll.max = maxX - width;
    hscroll.visible = true;
    } else {
    hscroll.value = 0;
    hscroll.visible = false;
    if (maxY > height) {
    vscroll.height = height;
    vscroll.layoutX = width - vscroll.width - 1;
    vscroll.max = maxY - height;
    vscroll.visible = true;
    } else {
    vscroll.value = 0;
    vscroll.visible = false;
    //Make sure the scrollbars don't overlap in the bottom right corner
    if (hscroll.visible and vscroll.visible) {
    hscroll.width -= vscroll.width;
    vscroll.height -= hscroll.height;
    view.width = maxX;
    view.height = maxY;
    function handleMouseDrag(dragX:Float, dragY:Float) : Void {
    if (allowDragScroll = false) return;
    if (vscroll.visible) {
    var newpos = saveVscrollVal + -dragY;
    if (newpos < vscroll.min)
    newpos = vscroll.min
    else if (newpos > vscroll.max)
    newpos = vscroll.max;
    vscroll.value = newpos;
    if (hscroll.visible) {
    var newpos = saveHscrollVal + -dragX;
    if (newpos < hscroll.min)
    newpos = hscroll.min
    else if (newpos > hscroll.max)
    newpos = hscroll.max;
    hscroll.value = newpos;
    }

  • Mouse click misses on all programs

    Every once in a while, like between every 10 seconds to 30 seconds, the mouse fails to register a click and I have to click again.
    It's a bluetooth mouse, but when I try with simply the trackpad I notice it occurs also.
    It's not always noticible, because it could be a miss-hit, but when I use a pro program , it really becomes noticible, and with mail too.
    I notice that sometimes when clicking on text to change a letter, the whole word is selected and sometimes the whole line.
    Is this a mouse malfunction?
    Is there something I'm doing wrong?
    I'm using a MacBook Pro 2.6 GHz Intel Core i7, 8GB Ram 1600 MHZ DDR3

    System Preferences > Accessibility > Mouse & Trackpad
    Double-click speed:
    Adjusting the speed may help.
    Best.

  • IE 11 launches OK (Win 8.1 system), but gives "Internet Explorer has stopped working" message when clicking on any/all links.

    As best I can recall, this happened after updating an Adobe program - probably Flash, but not sure.  Has anyone else encountered this?  I have not yet tried system restore because I'm not sure that's the answer.  If I roll back to the pre-Adobe
    update, Adobe will just prompt for the same update again and I could be caught in a revolving door.  Thanks. 

    Hi,
    Start>Event Viewer.... post back with the error stack.
    the first step in troubleshooting web browser issues is to test by running in noAddons mode. NoAddons mode leaves ActiveX enabled, but stops COM Addons and Extensions from being loaded. IE10+ has Tools>ActiveX filtering... some websites do not test
    for this and may think that Flash is not installed on the client.
    When posting internet related questions it is helpful if you include the full address of any websites you are having issues with.
    Regards.
    Rob^_^

  • Detect when mouse clicked over desktop

    hello guys,
    i have a graduation project working with networking, the instructor on the server side presents a powerpoint slide show an when he moves to the next slide, i have to send an order to the students (clients) to move to the next slide.
    can it be done???? plz if there is an example for both; the sender and receiver help me with it.
    tahnk you very much.

    http://forums.devshed.com/t311756/s.html
    http://forums.devshed.com/t311567/s.html
    http://forums.devshed.com/t311568/s.html

  • How do I create a new folder to use for my Outlook 365 mail account? I know with pc all I had to do was to right mouse click.

    Wondering how to create new folders for my Outlook 365 mail account. I know with pc all I had to do was to left mouse click.
    Any suggestions?

    New folder where? If you added the account in Mail app it should of created the folders to store that email automatically.
    What email program are you using?

  • Detect mouse clicks or keyboard events on desktop or everywhere

    Hi,
    What I have to do is to start the application minimized in the system tray. Then the application must be listening for crtl+shift+left mouse click in any part of the desktop or an opened application, when that happens, I have to show a window asking if the user want to take a screenshot starting in the x,y point he clicked and then take the screenshot.
    What I don't know how to do is to detect the mouse and keyboard events when the application is supposed to be running minimized in the system tray.
    How can I do that? Can anybody give me a hint?
    Thanks in advance.

    It's not possible with plain Java. You will need native code for this. Take a look at JNA.

  • Simulate any mouse click from webview

    How can I simulate any mouse click on any element of the site in webview ? (I have not managed yet to jquery and javascript control 100% of cases)

    http://forum.java.sun.com/thread.jsp?forum=4&thread=191468
    http://forum.java.sun.com/thread.jsp?forum=5&thread=135141
    http://forum.java.sun.com/thread.jsp?forum=54&thread=202069
    http://forum.java.sun.com/thread.jsp?forum=5&thread=11443
    this are some results of search applet browser +close                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Mouse clicking

    Hi all!
    Maybe it's too easy question, but I really appreciate your help!
    What listener should I use if I want to detect every mouse click
    wherever on the screen? When I add MouseListener to any Component,
    the MouseListener method mouseClicked is called only if I clicked
    on that component!
    many thanks

    What listener should I use if I want to detect every
    mouse click
    wherever on the screen?A native one.

  • Mouse clicks occasionally stop working

    I am currently deploying a Java Swing application, and sometimes the end-user encounters an unusual problem whereby they open the application and mouse clicks have no effect. The mouse movement is still tracked fine, as buttons and menus get highlighted as expected when the mouse passes over them. I searched for information about this problem, and learned that a work-around is to click the middle mouse button. This does indeed restore the mouse click behaviour and all continues to work fine after that.
    So then I thought I might simulate a middle-button mouse click during my application start-up, in the hope of remedying the problem before any end-user actually sees it. The result is that instead of remedying the problem, I actually cause it to happen every time! The application gets into a state whereby mouse clicks are ignored, and clicking the middle-mouse button restores the mouse click behaviour.
    Has anyone else experienced this problem, and know of a way to prevent end-users from experiencing this problem? Here's some example code that demonstrates the behaviour:
    import java.awt.Robot;
    import java.awt.event.InputEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class Main
        public static void main(String[] args)
            JFrame frame = new JFrame();
            frame.getContentPane().add(new JButton("Click Me"));
            frame.pack();
            frame.setLocationRelativeTo(null);
            try
                // Simulate a middle-button mouse click
                Robot robot = new Robot();
                robot.mousePress(InputEvent.BUTTON2_MASK);
            catch (Exception e)
                e.printStackTrace();
            frame.setVisible(true);
    }Note I'm using Java 1.6.0_07. Any help with this would be much appreciated,
    Paul.

    import java.awt.Robot;
    import java.awt.event.InputEvent;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    public class Main
        public static void main(String[] args)
            JFrame frame = new JFrame();
            frame.getContentPane().add(new JButton("Click Me"));
            frame.pack();
            frame.setLocationRelativeTo(null);
            try
                // Simulate a middle-button mouse click
                Robot robot = new Robot();
                robot.mousePress(InputEvent.BUTTON2_MASK);
                // Simulate a middle-button mouse click again
                robot.mousePress(InputEvent.BUTTON2_MASK);
            catch (Exception e)
                e.printStackTrace();
            frame.setVisible(true);
    }?

  • Every keystroke or mouse click results in a 10 sec or more delay before responding. Suggestions??

    Each time I type something or click my mouse, there is a delay before the keystrokes are recognized, or the mouse click has any results. This delay be as little as 5 secs but go up to as much as 15 secs. Very frustrating and a time waster if you add it all up.

    @<b>nikcree</b>
    Please start a new thread for your problem or question and provide troubleshooting information like your operating system and installed extensions and installed plugins.
    *[[/questions/new start a new thread]]
    *[[/kb/Using+the+Troubleshooting+Information+page]]
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    <i>[locking this thread due to age]</i>

  • Mouse clicking disappears

    For some reason, my Macbook has suddenly decided to stop accepting any form of clicking.
    The trackpad works in the scroll up and down, but tapping doesn't register a click and neither does pressing the actual click button below the trackpad.
    I thought it may have been the trackpad that has broken, but when I plugged in an external mouse, it's the same - you can move the mouse around, but just not click.
    PRAM etc has been reset, but it still doesn't want to recognise a mouse click from any device, whether it be the built in trackpad or an external mouse.
    Re-install help? I thought at first a hardware error, but with an external mouse giving the same results, could it be software?

    I have a simmilar problem, but in my case the mouse clicking doesn't disappear completely. Sometimes it works, sometimes it doesn't. Most of the time the mouse refuses to work when surfing the web. It doesn't matter if I use Safari or Firefox, I'm not able to click on some of the links - other links work fine. After a reboot the working and not working links get shuffled, different links work and different links don't work. I have this problem with the mouse as well as with the trackpad. It also seems to depend on screen area - sometimes, when I click on a certain link it refuses to work unless I click on a different area of the same link.

  • Passing through a mouse click

    I have a canvas with backgroundAlpha=0 over some other components, so that I can use rollOver and rollOut to trigger some events. However, i can't get the mouse to work with the components underneath the tranparent canvas. Is there a way to pass the mouse click event on to the components underneath the canvas?
    thanks,
    jq

    Thanks very much for your answer.
    In my case, I have a List which already has click actions assigned to its items. Basically, I want the list to disappear when the mouse is out of it, an reappear when the mouse is over it. For this purpose, I overlayed it with a transparent canvas, which responds to rollOver and rollOut. But then the list no longer responds to the mouse clicks. Is there a way to get the overlayed convas to pass the mouse click to the list so it responds normally again?
    jq

Maybe you are looking for

  • Apple TV will no longer Sync and YouTube Not Working

    Recently my Apple TV (160GB version) has stopped syncing with my copy of iTunes. Previously it synced fine and when ever I lunched iTunes it would show up under my devices. But now it behaves rather strangely. Every now and again my Apple TV shows up

  • Excel Chart : operations on series using active X

    I use Active X to display XY graphs and its corresponding data on an excel sheet but i have difficulties playing with the series. For example, the first graph corresponds to f(B)=A where A and B are excel columns, and the second corresponds to f(C)=A

  • Open item managemet in GL account

    Dear Experts, I need to activate Open item management field for one GL account where there is already documents are posted, but balance is "Zero". Please let me any procedure to activate this (other than by changing message typeA)? Is there any progr

  • Trying Creative Cloud - Photoshop CS6 asking for a serial number?

    I am trying out Creative Cloud and have previously used trial version of Photoshop CS6 Extended.  Have downloaded Photoshop CS6 via creative cloud but when try to run it I get a message that I must enter a serial number.  Can anyone help ?

  • Setup WRT160N only for business hours

    I looking to set up my Wireless router to be only Active wireless signal from 6 am to 6 pm Monday thru friday. I want to do this keep my Work network more secure. Does any one know how to set this up. Thanks Jim