Mouse Events on Disabled Buttons

Hi,
In my application I should make a disabled button to show a tool tip when mouse is entered onto it.
I'm using java.awt.container not Jcontainer.
I have searched in SDN forums and after reading some of the comments what I understood is �disabled Swing button can react to Mouse events but a disabled awt button can not react to mouse events�.
Is that true or did I not understand correctly?
And how would I be able to implement the required functionality in my
application?
Thanks.

import java.awt.*;
import java.awt.event.*;
public class AwtTooltip {
    private Panel getContent(Frame f) {
        Button left = new Button("left");
        left.setEnabled(false);
        Button right = new Button("right");
        Panel panel = new Panel(new GridBagLayout());
        new TipManager(panel, f);
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.weightx = 1.0;
        panel.add(left, gbc);
        panel.add(right, gbc);
        return panel;
    public static void main(String[] args) {
        AwtTooltip test = new AwtTooltip();
        Frame f = new Frame();
        f.addWindowListener(closer);
        f.add(test.getContent(f));
        f.setSize(300,100);
        f.setLocation(200,200);
        f.setVisible(true);
    private static WindowListener closer = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
class TipManager extends MouseMotionAdapter {
    Panel component;
    Window tooltip;
    Label label;
    public TipManager(Panel panel, Frame frame) {
        component = panel;
        panel.addMouseMotionListener(this);
        initTooltip(frame);
     * Since enabled Buttons consume MouseEvents we will
     * receive events sent only from disabled Buttons.
    public void mouseMoved(MouseEvent e) {
        Point p = e.getPoint();
        boolean hovering = false;
        Component[] c = component.getComponents();
        for(int j = 0; j < c.length; j++) {
            Rectangle r = c[j].getBounds();
            if(r.contains(p)) {
                hovering = true;
                if(!tooltip.isShowing())
                    showTooltip(c[j], p);
                break;
        if(!hovering && tooltip.isShowing()) {
            tooltip.setVisible(false);
    private void showTooltip(Component c, Point p) {
        String text = ((Button)c).getLabel();
        label.setText(text);
        tooltip.pack();
        convertPointToScreen(p, component);
        tooltip.setLocation(p.x+10, p.y-15);
        tooltip.setVisible(true);
    /** Copied from SwingUtilities source code. */
    public void convertPointToScreen(Point p, Component c) {
        Rectangle b;
        int x,y;
        do {
            if(c instanceof Window) {
                try {
                    Point pp = c.getLocationOnScreen();
                    x = pp.x;
                    y = pp.y;
                } catch (IllegalComponentStateException icse) {
                    x = c.getX();
                    y = c.getY();
            } else {
                x = c.getX();
                y = c.getY();
            p.x += x;
            p.y += y;
            if(c instanceof Window)
                break;
            c = c.getParent();
        } while(c != null);
    private void initTooltip(Frame owner) {
        label = new Label();
        label.setBackground(new Color(184,207,229));
        tooltip = new Window(owner);
        tooltip.add(label);
}

Similar Messages

  • Mouse Event consumption on Button(s)

    Hi,
    I have a base screen (window A) with an OnClick events covering the screen.
    I have a popup window (window B) which can overlay this screen.
    This contains 3 FX Buttons X, Y, Z . The action: function() is coded on each one
    X and Y are OK, Cancel buttons (which close Window B)
    Z launches another popup (Window C ) (again overlaying the middle window) which has again onClick events all over it which closes Window C.
    Problems
    1) If the user clicks on button Z - Window C opens, then immediately closes again (because of the onClick event in window C)
    2) If the user clicks X or Y , Window B closes but then launches the OnClick event on window A
    I have blocksMouse : true all over the place but I can't seem to stop the onClick events triggering...
    Any one can shed a light how to consume the continuing mouseEvent caught(?) by the action: function() on the Button
    Cheers,
    ScottyB

    Ok, I agree and thought that too.
    OK , so this scenario has a little twist to it (as all my seem to have ;-)
    It also involves a call back event in each action().
    One to close the window from the parent window, the other to pass a selected string.
    Neither of which I think are too much to ask and should not affect the idea of mouseClicked consumption.
    Anyway have a look - please give it a run (just incase its my setup - although I am pretty up todate 1.6.0.14)
    I have been moving blocksMouse commanda round so feel free to do so yourself - I do not think it helps in this case.
    Click on the Black Square to start
    Main.fx
    package testbed.test05;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.input.MouseButton;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    import java.lang.Void;
    public var group:Group = Group {
        content:[]
    def windowB:WindowB = WindowB {
            translateX: (640 - 200 )/2,
            translateY: (480 - 200)/2
            onClose:function():Void {
                delete windowB from group.content;
            blocksMouse:true
    def editButton:Rectangle = Rectangle {
           translateX: 550
           translateY: 200
            width: 50, height: 50
            fill: Color.BLACK
            blocksMouse: true
            onMousePressed: function( e: MouseEvent ):Void {
                println("Edit Button Pressed...");
                if (e.button == MouseButton.PRIMARY) {
                    insert windowB into group.content;
    public def myStage:Stage = Stage {
        title: "Buttons"
        width: 640
        height: 480
        scene: Scene {
            content: bind [group,editButton]
    var windowA:WindowA;
    function runApplication() {
        windowA =  WindowA    {}
        insert windowA into group.content;
    function run() {
        runApplication();
    }WindowA.fx
    package testbed.test05;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.input.MouseButton;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.Node;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    public class WindowA extends CustomNode {
        var boxfill:Color = Color.GREEN;
        def rect =  Rectangle {
                    width: 640
                    height: 480
                    fill: bind boxfill
        public override function create(): Node {
            return Group {
                content: bind [rect]
                onMouseClicked: function( e: MouseEvent ):Void {
                    if (e.button == MouseButton.PRIMARY) {
                        println("Window A clicked:{id}");
                        boxfill = Color.RED
    }WindowB.fx
    package testbed.test05;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.Node;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.effect.DropShadow;
    import javafx.scene.control.Button;
    public class WindowB extends CustomNode {
      public var onClose:function():Void;
      def drop  = DropShadow {
                        offsetX: 3
                        offsetY: 3
                        radius: 20
      def background = Rectangle {
            blocksMouse:true
            width: 200
            height: 200
            fill: Color.BEIGE
            arcHeight:20
            arcWidth:20
            effect: drop
        def imageButton =  Button {
            translateX: 100,
            translateY: 100
            text: "Button Z..."
            action: function() {
                   var windowC: WindowC = WindowC {
                                            onSelection: function(selection:String):Void {
                                                        println(selection);
                                            translateX: (640 - 200 )/2,
                                            translateY: (480 - 200)/2
                insert windowC into Main.group.content;
        def buttonX:Button  = Button {
            blocksMouse:true
            text: "Button X"
            action: function() {
                println("Clicked Button X");
                onClose();
            def buttonY = Button {
            blocksMouse:true
            text: "Button Y"
            action: function() {
                println("Clicked Button Y");
                onClose();
        public override function create(): Node {
            buttonX.translateX = background.width - buttonX.layoutBounds.width - buttonY.layoutBounds.width - (2 * 10);
            buttonY.translateX = background.width - buttonY.layoutBounds.width - (1 * 10);
            buttonX.translateY = background.height - buttonX.layoutBounds.height - (1 * 10);
            buttonY.translateY = background.height - buttonX.layoutBounds.height - (1 * 10);
            return Group {
                content: [background,imageButton,buttonX,buttonY]
    }WindowC.fx
    package testbed.test05;
    import javafx.scene.CustomNode;
    import javafx.scene.Group;
    import javafx.scene.Node;
    import javafx.scene.effect.DropShadow;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.scene.input.MouseEvent;
    public class WindowC extends CustomNode {
        public var selectedLine:String = null;
        public var onSelection: function(:String):Void;
      def drop  = DropShadow {
                        offsetX: 3
                        offsetY: 3
                        radius: 20
      var clicked:String = "You have clicked inside Window C";
      def background:Rectangle = Rectangle {
            width: 400
            height: 400
            fill: Color.BLUE
            arcHeight:20
            arcWidth:20
            effect: drop
            onMouseClicked: function( e: MouseEvent ):Void {
                onSelection(clicked);
                delete this from Main.group.content;
        public override function create(): Node {
            blocksMouse = true;
            return Group {
                content: [background]
    }

  • Possible to receive event on disabled frame?

    I have an application that have many JFrame popups. After 15 minutes, the app will automatically lock all windows calling their setEnabled(false). A Lock window is displayed let user to relogin.
    When user click on any of open frame, I would like to display Locked frame by user's cursor. However, the inactive windows are not receiving any mouse event.
    Anyone have good idea on how to intercept mouse event on disabled JFrame?
    Thanks.

    817011 wrote:
    I have an application that have many JFrame popups. .. That is where you start to go wrong. Have just one <tt>JFrame</tt> & show other information as <tt>JDialogs</tt> or alternately include it in the main <tt>JFrame</tt> using a <tt>CardLayout</tt>, <tt>JTabbedPane</tt>, <tt>JDektopPane/JInternalFrame</tt> or similar.
    ..After 15 minutes, the app will automatically lock all windows calling their setEnabled(false). A Lock window is displayed let user to relogin.Put the login GUI into a modal <tt>JDialog</tt> and provide the <tt>JFrame</tt> as the parent.
    The user will not be able to access the <tt>JFrame</tt> until the <tt>JDialog</tt> is dismissed.

  • Disabled button does not look disabled

    In a simple FX app I created a button and set the disable property to true, for exampledeleteButton.disable = true The problem is that when I run the app the button does not look disabled. The only way I can tell if the button is enabled or disabled is by mousing over it: if I mouse over a disabled button nothing happens, if I mouse over an enabled button it flashes blue.
    Is this a bug either FX or Nimbus, or am I doing something wrong?
    Cheers, Eric

    I've found the same problem and a "bugy way"
    if in a Custom node:
    var bts: Button[];
    function setControl(b: Boolean) {
            for (bt in bts) {
                bt.disable = not b;
    postinit {
            Timeline {
                keyFrames: KeyFrame {
                    time: .2s
                    action: function(): Void {setControl(false)}
            }.playFromStart();
    public override function create(): Node {
            insert Button {
                //disable: bind not control
                text: "View"
                action: function(): Void {
                    onView(boxNumber);
            } into bts;
            insert Button {
                //disable: bind not control
                text: "Print"
                action: function(): Void {
                    onPrint(boxNumber);
            } into bts;
                            VBox {
                                layoutInfo: LayoutInfo {
                                    width: 80
                                spacing: 5
                                content: [
                                    bts
    ...Afterall it put an shinny effect on your screen, thank's javafx.control API ;-)

  • Unhandled mouse events

    I had a problem and solved it, but I don't like the solution and still don't get the problem. So, I hope somebody can explain:
    I am using TestStand in combination with a LabWindows/CVI Operator Interface. At a certain point I have to open a second LabWindows/CVI UI application (reused for some specific operator interaction). An operator eventually closes the second UI via a 'Close' button. However, the UI does not respond to mouse events on the button. The UI does respond to the shortcut keys (Esc or Alt-C).
    I discovered that it is not the first UI (the Operator Interface) that is 'stealing' the events. It appears that TestStand does not allow the UI to process the events. As soon as a Message Popup step is being executed the events are handled. So, we made TestStand periodically verify whether the Close button was pressed in a call to the second UI. In the UI we first call ProcessSystemEvents. This worked pretty well. But, then I decided to neatly place the periodic poll in a separate sequence running in a separate thread. Again I ran into the same problem. So, the TestStand execution really has to get interrupted and I am forced to pollute my sequence files with the periodic polls. Boeh hoe :-(
    Greetz,
    David Meijers

    Bas,
    I will try to extract a usefull stand-alone example out of our complete system. It might take a while though, because I have a workaround (so, I will try finding the problem in spare time for the better of mankind ).
    Greetz, David

  • ComboBox screws up mouse events

    I'm having a problem where after selecting something from a
    comboBox, the
    mouse events sent to buttons and movieClips (that have
    nothing to do with
    the comboBox) no longer work correctly.
    After using the comboBox, if you click on a button or
    movieClip, without
    moving the mouse, the button or movieClip no longer receives
    mouse events
    until the mouse is moved.
    This is most noticable with something like a "Next" button,
    that is clicked
    repeatedly without moving the mouse. The first click will
    work, then other
    clicks will stop working (as well as rollOver). If you move
    the mouse just
    one pixel over, then it works again.
    This is easily reproduced in a test fla. Create a button that
    traces
    "press" and "release". Put a comboBox on the stage with a few
    items and be
    sure to name the comboBox instance.
    Has anyone experienced this and has a workaround. The only
    workaround I
    have found is to not use comboBox..

    OK, I still think this is a bug, but I've found a workaround:
    The problem is that the comboBox contains an input text
    field, and even if
    you have the comboBox's editable property set to false, the
    input text field
    gets FOCUS when you click on the comboBox. Then when you go
    and click on
    the button, the input text field still has focus, and not the
    button. Why
    the button stops working after the first click and release is
    what seems
    like a bug. The button does not have focus and clicking on it
    doesn't give
    it focus. You can see the same thing if you put an input text
    field on the
    stage, play the movie and click in the text field. Even
    though you are
    clicking on the button, the i-beam is still blinking in the
    text box, and
    you will see the same messed up functionallity that I
    originally described.
    Here is the workaround. You have to explicitly give the
    button focus.
    _focusrect = false; // don't want yellow box around item in
    focus
    test_btn.onPress = function() {
    trace("press");
    focusManager.setFocus(this); // this sets focus back to the
    button
    test_btn.onRelease = function() {
    trace("release");
    Chris
    "Chris" <[email protected]> wrote in message
    news:[email protected]...
    > I'm having a problem where after selecting something
    from a comboBox, the
    > mouse events sent to buttons and movieClips (that have
    nothing to do with
    > the comboBox) no longer work correctly.
    >
    > After using the comboBox, if you click on a button or
    movieClip, without
    > moving the mouse, the button or movieClip no longer
    receives mouse events
    > until the mouse is moved.
    >
    > This is most noticable with something like a "Next"
    button, that is
    > clicked
    > repeatedly without moving the mouse. The first click
    will work, then
    > other
    > clicks will stop working (as well as rollOver). If you
    move the mouse
    > just
    > one pixel over, then it works again.
    >
    > This is easily reproduced in a test fla. Create a button
    that traces
    > "press" and "release". Put a comboBox on the stage with
    a few items and
    > be sure to name the comboBox instance.
    >
    > Has anyone experienced this and has a workaround. The
    only workaround I
    > have found is to not use comboBox..
    >
    >
    >

  • Mouse Clicks' Queue when Button is Disabled

    Hi, I was wondering about the Disable property for UI
    Components.
    In the docs it says that when the component is disabled it
    ignores all
    interaction whatsoever - in particular - user interaction.
    In my case, the button is disabled for a few seconds right
    after it
    was clicked by the user (I disable it till the httprequest is
    returned
    and then enable it).
    What happens is that if the user clicks the button while it's
    disabled
    - nothing happens. But when the button turns enabled - it
    acts as if
    it just got the click event.
    It seems like the mouse click event went into this queue and
    the
    button listened to it right after to turned enable?
    Am I correct? If so - how can I prevent this problem?
    If I'm wrong, what's the reason for this? And again, how can
    I sort
    this so the user can't send mouse clicks to the button when
    it's
    disabled??
    Many thanks :)
    Gilad

    "giladozer" <[email protected]> wrote in
    message
    news:gnbng6$o6m$[email protected]..
    > Hi, I was wondering about the Disable property for UI
    Components.
    > In the docs it says that when the component is disabled
    it ignores all
    > interaction whatsoever - in particular - user
    interaction.
    > In my case, the button is disabled for a few seconds
    right after it
    > was clicked by the user (I disable it till the
    httprequest is returned
    > and then enable it).
    > What happens is that if the user clicks the button while
    it's disabled
    > - nothing happens. But when the button turns enabled -
    it acts as if
    > it just got the click event.
    > It seems like the mouse click event went into this queue
    and the
    > button listened to it right after to turned enable?
    > Am I correct? If so - how can I prevent this problem?
    > If I'm wrong, what's the reason for this? And again, how
    can I sort
    > this so the user can't send mouse clicks to the button
    when it's
    > disabled??
    No idea about whether you're correct or wrong, but you might
    want to try
    setting mouseEvents = false on the button and see if that
    helps.

  • Mouse events don't work on a button from a panel ran in a DLL

    Hi.
    I have a DLL that loads a panel.
    Since it's a DLL I can't do the RunUserInterface() function, because the DLL would be stuck waiting for the panel events.
    I only do the LoadPanel().
    When I click with the mouse on one of the buttons, the pushing down event (simulating the button being pressed) doesn't happen and the callback doesn't run.
    But if I press the tab button until the focus reaches the button and press Enter, the callback of the button is executed.
    An even more interesting aspect is that this happens when I call the DLL on TestStand, but on an application of mine that calls the DLL just for debug everything works fine.
    How can I enable the mouse events?
    Thanks for your help.
    Daniel Coelho
    VISToolkit - http://www.vistoolkit.com - Your Real Virtual Instrument Solution
    Controlar - Electronica Industrial e Sistemas, Lda
    Solved!
    Go to Solution.

    Hello Daniel,
    I got surprised when I read your post, because I am experiencing something almost the same as you do.
    I have a DLL (generated by an .fp instrument driver I wrote) which performs continious TCP communication with the UUT.
    It starts 2 threads, each for reading from one of the 2 different IPs the UUT has.
    Another DLL tests this UUT (with the help of the communication DLL above) by exporting functions to be called by TestStand steps.
    If the second DLL wants to display a CVI panel in order to wait for the user response or displays a popup (MessagePopup, ConfirmPopup, etc), user cannot press the buttons.
    Actually, there is a point your program and mine differ. I call RunUserInterface and the button's callbacks call QuitUserInterface, so the execution continues after a button is pressed. The problem is buttons cannot be pressed. I also tried looping on GetUserEvent  but it did not solve the problem.
    There are 2 findings:
    1. I had a small exe to test my instrument driver DLL and the popups in it worked pretty well (this coincides with Daniel's findings).
    2. We workedaround the problem by shutting down the communication threads in the instrument driver DLL before the popup appears and restrating them afterwards. Although they are separate threads in another DLL, they were somehow blocking user events on another DLL running.
    S. Eren BALCI
    www.aselsan.com.tr

  • Disabling mouse events

    hi,
    I am having objects on a JFrame that respond to mouse events. I would like to know how I can disable these events. I use the addMouseListener to register a mouse event on something. Is there a way to remove or to deregister mouse events.
    I basically have a game of tiles on a JFrame and I am going to have the human player play against the computer. I want to be able to have turns; computer and human player turn.

    removeMouseListener()

  • Event handling with buttons and mouse

    Hi, Im a beginner in Java...!!!
    I have 4 buttons with me- 2 for color(red,blue) and 2 for size(big,small)..
    How do we divide the frame into 2 panels..one for Buttons and Other for Mouse events...
    Now,if I click on RED button and BIG button..and later click in the Mouse Panel area..I shud get a big rectangle filled with red color..and similarly for small / blue..etc...if a new selection is made..the previous rectangles should remain as they are...
    Im unable to get the implementation...any help will be appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    class ButtonPanel extends JPanel
    implements ActionListener, MouseMotionListener
    {  public ButtonPanel()
    blueButton = new JButton("Blue");
    redButton = new JButton("Red");
    bigButton = new JButton("Big");
    smallButton = new JButton("small");
    add(blueButton);
    add(redButton);
    add(bigButton);
    add(smallButton);
    blueButton.addActionListener(this);
    redButton.addActionListener(this);
    bigButton.addActionListener(this);
    smallButton.addActionListener(this);
    public void actionPerformed(ActionEvent evt)
    Color color = getBackground();
    repaint();
    // Paint Method
    public void paintComponent(Graphics g)
    {  super.paintComponent(g);
    class ButtonFrame extends JFrame
    {  public ButtonFrame()
    {  setTitle("ButtonTest");
    setSize(300, 200);
    addWindowListener(new WindowAdapter()
    {  public void windowClosing(WindowEvent e)
    {  System.exit(0);
    Container contentPane = getContentPane();
    contentPane.add(new ButtonPanel());
    public class ButtonTest
    {  public static void main(String[] args)
    {  JFrame frame = new ButtonFrame();
    frame.show();
    }

    can U kindly code it for me....!!!you're getting closer,
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=011033but rent-a-coder is that way ---->

  • Disabled button fires an event ?!   :-O

    Hi, friends!
    I've never thought about the next issue: why desabled button can fire an et_Click event?
    I havn't no idea to check that!
    I thought before that enabled=false is the method to prevent et_Click event for that item, but...
    <b>Is it a bug or feature?</b>
    I'm talking now about v6.5, what can you say about that situation on v6.7?

    It is not a bug, the SDK is simply informing you that the user clicked on something.  You can click on other disabled items such as edittexts and they will also generate the click events for you. 
    The important difference with a disabled button is that the et_ITEM_PRESSED event won't be triggered.  The et_ITEM_PRESSED event is the correct one to use to detect the user pressing a button.
    John.

  • Disabled button fires events to event structure

    Hi all,
    I was trying to disable a Button on the frontpanel by using its enabled property while the event was executed. The ide wa not to create more events of this buttopn while its fucntion was executed. However thsi did not work.It was creating events even though it was greyed out.
    I troied two different versions:
    1) in the event case of the button (value changed) in a sequence I first dispalbned the button, execuded the code and then enabled it again
        Result: All events were generated even though the button was greyed out
    2)  in the event case of the button (value changed) in a sequence I disbaled the Button and then started a second event. The Second event executed the code and then enabled the Button egain
       Result: Even though the Button was greyed out events were generated
    3) in the event case of the button (value changed) in a sequence I first dispalbned the button, execuded the code and in the timeout event I thenenabled it again
       Result: No additional events were generated
    it seems that the enable state of the button is analysed at teh time when the event is execute din teh event case but not at the time when it was created?
    So I Tried the Time Input of the case expecting that it woudl give me a time stamp of the time when the key was pressed - but instead it gave me the time point when teh event was executed...
    Teh only othe rsolution was to set teh cursor to busy (however I dont want to see the changed cursor during the busy cycle)
    So how can I make shure that no additional events are fired during the time teh code of the Button s executed?
    Thanks for any help,
    Rainer

    to altenbach:
    The evet takes about one or two seconds - I checked the behaviour as shown in the attached examples with LV 8.5, LV 2010, TV2011, LV2012 - allways exactly the same behaviour.
    It does not make any difference weather you use switch when pressed or latched when pressed.
    It does not make any difference weathe ror not you tag "Lock front panel" for that event
    to sth:
    > If you disable a front panel control (ie the button) you cannot click on it and a value changed event will not be
    generated.
    This is my experience so far as well, but if you disable and enable the control within the same event it does not work (see attaced example 1) and 2). It only works if you do the enable in the timeout event.
    > The time stamp from the event case left hand property is the time of the event not the time of execution.
    > If you ask for the timer value inside the event case it will be the time of event case executing.
    In the attached exampel this is not the case. The time differecne between the Time input on the left and the Tick count
    placed in the event is 0 for all events generated whil the button is supposed to be disabled.
    As I wrote before, the explanation I have for this behaviour is that the events are generated by windows weather or not
    the button is disabled and they are queued to the event cue. Only when the event is handeled LabVIEW tests weather
    or not the button is disabled and ignores the event in case it is disabled. If the Disabling and enabling is done
    withim the same event the button pressed events are added to thw event queue and the button is set to enabled before the  next event (button pressed while it shoul be disabled) is handeled. When that event is handeled the button is enabled again (by the original event) and therefore the evenet is not ignored (because by the time of execution of the event the button is enabled again).
    If the button is enabled in the timeout event instead of the button change value event all event in teh queue are executed before teh timeout event. At their time of execution therefore the button is steill disabled. Only then the timeout event enables the button again.
    If the vi is set to busy (sand clock) this is activating actually a windows function/property and no events are queued to teh event queue by windwos. Therefore no button change event is added to teh queue.
    Funtciomn of the 3 attached Vis (LV 2010):
    Run the Vi, then press the Test button once - when it is greyed out click it a few more times. The test button value
    changed event has a 2 second delay. You will see the event counter increase, and you will see the time difference
    between the time property on the left of the event and the tick count vi whci is displayed in the waveform chart.  
    DisableButton 1: Disable and enable are ste in teh same event  
    DisableButton 2: The button is disabled then a second event is called to do the work and then enable teh button again
    DisableButton 3: The Button is disabled in button change value event and it is enabled again in teh timeout event.
    Attachments:
    DisableButton1-3.zip ‏29 KB

  • Disabled button generates events

    Hello,
    I have a radio button that I want to disable while a background process is running.
    After the process finishes, I enable the button again.
    However, if the user clicks on the disabled button during the background process, an ActionEvent still gets generated.
    Then when the button is re-enabled, it responds to the event that was generated while it was disabled. I want to prevent my button from responding to events generated while it was disabled.
    I do not want to use the getGlassPane.setVisible(true) technique because I still want my cancel button to be able to generate events during the background process.
    I am using JDK 1.3.1 and my button is in a panel contained in a JFrame application.
    Suggestions?
    Thank you,
    Ted Hill

    Hello,
    I have a radio button that I want to disable while a background process is running.
    After the process finishes, I enable the button again.
    However, if the user clicks on the disabled button during the background process, an ActionEvent still gets generated.
    Then when the button is re-enabled, it responds to the event that was generated while it was disabled. I want to prevent my button from responding to events generated while it was disabled.
    I do not want to use the getGlassPane.setVisible(true) technique because I still want my cancel button to be able to generate events during the background process.
    I am using JDK 1.3.1 and my button is in a panel contained in a JFrame application.
    Suggestions?
    Thank you,
    Ted Hill

  • DISABLE MOUSE EVENT on jlabel

    Dear all,
    I have a jlabel on which i perform a click and the embbeded image switch between start and stop image.
    My problem consists in preventing from performing multiples click/or disabling mouse event while the application starts loading some parameters.
    switchViewLabel.addMouseListener(new MouseAdapter() {
                   public void mouseClicked(MouseEvent e) {
                        //it takes a long time
                                   onSwitchViewButtonClick();
    protected void onSwitchViewButtonClick() {
              System.out.println("onSwitchViewButtonClick");
              if (canGo) {
                   System.out.println("canGo");
                   canGo = false;
                   MainWindowPeer.getInstance().setCursorToWait();
                         //this action load parameter
                            CommandWindow.getInstance().switchView();
                         refreshSwitchViewButton();
                   MainWindowPeer.getInstance().setCursorToDefault();
                   canGo = true;
         } But on my console i have noticed :
    canGo
    onSwitchViewButtonClick
    canGo
    onSwitchViewButtonClick
    canGo.....
    It looks like we store mouse event anywhere and for each event we execute onSwitchViewButtonClick code and consume event.(it seems to not be asynchronous)....
    How to do ???
    Thanks for any helps..

    Dear all,
    yes i want to ignore mouse events until the processing is done.But how to perform process in separate thread and what is a semaphore.Is it possible to have much more explanation...
    Shall i do following code..
    mouseAdapter = new MouseAdapter() {
                   public void mouseClicked(MouseEvent e) {
                        SwingUtilities.invokeLater(new Runnable(){
                             public void run() {
                                  //switchViewLabel.removeMouseListener(mouseAdapter);
                                  onSwitchViewButtonClick();
                                  //switchViewLabel.addMouseListener(mouseAdapter);
              };Thanks you in advance...

  • Disable JTree and stop it from receiving mouse events

    Hi,
    I have a JTree which has a mouse listener associated with (which is used for right-click operations)..,..anyway I am trying to disable the tree, so I call setEnabled(false)...which, as documented, disables the tree but it will still receive mouse events. I also tried, setEditable(false)..... the only way I can think of is to remove the mouse listener, and then when I want to re-enable the tree, I have to add it back.
    is there some other way?
    thanks

    Hi,
    I have a JTree which has a mouse listener
    ner associated with (which is used for right-click
    operations)..,..anyway I am trying to disable the
    tree, so I call setEnabled(false)...which, as
    documented, disables the tree but it will still
    receive mouse events. I also tried,
    setEditable(false)..... the only way I can think of
    is to remove the mouse listener, and then when I want
    to re-enable the tree, I have to add it back.
    is there some other way?Why do you want another way? This seems like a perfectly viable way to accomplish what you want.

Maybe you are looking for

  • XE beta install on windows xp - SOLUTION

    Hi All, after trying to install the XE beta on a couple of windows xp (with sp2) domain connected machines, i think i can finally provide an outline on how to go about and do it successfully. After all installations (no matter if the logged in accoun

  • Itunes starts then windows says it has stoped and must close

    Itunes was working just fine on my sons laptaop. Then he decided to by an ipod nano (8GB) Friday night. He gets home hooks it up and gets the message that the ipod needs I tunes 7.4 or greater so upgrades. Now every time he opens i tunes windows syay

  • Best way to display a fillable pdf in the browser?

    I am currently using the code below( .net using C#)  to display my pdf which is in a memory stream to the browser:                 this.Response.Buffer = false;                 this.Response.Clear();                 this.Response.ClearContent();     

  • How to place grouped items into another object with content collector tool?

    Is it possible to paste a group into another object (i.e. frame) by using the Content Collector Tool while linking the content?  Paste Into is either deselected or possibly whatever was last saved to the clipboard ends up inserting. I was able to pla

  • Photoshop Premier Elements 9 requires SSE2

    I have a 2004 computer Windows Home Ed.  Can I download this SSE2 thingamy?