Different 'mouse enter' event / 'set busy' vi behaviour in LV8?

In my program, I used the mouse curcor 'set busy' vi to lock the front panel during a measurement.  However, I did want the 'cancel measurement' button to be available.   I solved that by adding a 'mouse enter' and 'mouse leave' event for that button, that would enable the mouse when it was over the button.  (And disable when it left again)
Worked fine in LV7, but it seems that in Labview 8, this little trick doesn't work anymore...   
Apparantly, now the 'mouse enter' event only fires when the cursor isn't set to 'busy'. How do I perform something similar to my old trick in Labview 8? 

I too had a similar issue when upgrading my application source code from LabVIEW 7.1 to 8.0.  There are a couple of things you could try.
1) Keep calling the "set cursor busy" vi, but don't disable mouse clicks (a boolean input to the set busy VI). Now add a new event to your event structure to monitor the panel for any "mouse down?" events.  Whenever this event occurs, the user is trying to click somewhere, so wire a TRUE to the "Disabled?" input of the event.  Now to keep your cancel button from being filtered out, add some code to determine if the x,y coordinates of the mouse down event are over your cancel button, if so then don't filter this event.
2) Keep calling the "set cursor busy" vi, but again don't disable the mouse clicks.  Now whenever you want to disable all user events on your front panel controls, open a reference to each front panel control and set it to disabled (all except the cancel button of course).  This sounds difficult, but it is actually really easy.  There is a VI property you can read to get references to each FP control.
I personally used the 2nd option in my code to do something similar.  I've attached the VI you can use to disable all you FP controls (with exceptions), and also an example of how I used it.  It's a very small VI.
Hope this helps.
Attachments:
SetAllCtrlsToDisabled.zip ‏24 KB

Similar Messages

  • Not detecting mouse exit events

    I'm developing a Java application that implements an 'auto-hide' functionality - similar to that of the Office Shortcut bar - such that when the mouse moves outside of the application frame the window auto-hides. I'm using the Mouse Exit event to detect when the mouse moves outside of the the application frame and then I 'hide' the window (or rather resize it to 2 pixels high) so I can then detect the Mouse Entered event to restore the window.
    This works OK but occasionally if I move the mouse quick enough the exited event isn't detected and the window doesn't always hide.
    Are there any other ways of detecting if the mouse moves outside of the application frame (so I can also trigger my 'hide' function) without relying on other events such as windowLostFocus.
    Thanks,
    Richard.

    I have one suggestion:
    Check that the component that you use to monitor mouse exit and enter events has at least one pixel visible from all sides (most layout managers allow a border (not a Border class or subclass) that is not occupied by child subcomponent).
    For example if you will place some other component in container directly so some side then mouse enter and exit events will be fired on that component and not on the container.

  • Mouse Drag in JDialog produces Mouse Enter & Mouse Exit events in JFrame.

    Hi, all.
    Do I have a misconception here? When I drag the mouse in a modal JDialog, mouseEntered and mouseExited events are being delivered to JComponents in the parent JFrame that currently happens to be beneath that JDialog. I would not have expected any events to be delivered to any component not in the modal JDialog while that JDialog is displayed.
    I submitted this as a bug many months ago, and have heard nothing back from Sun, nor can I find anything similar to this in BugTraq.
    Here is sample code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * This class demonstrates what I believe are TWO bugs in Mouse Event handling in Swing
    * 1.1.3_1, 1.1.3_2, 1.1.3_3, and 1.4.0.
    * 1) When a MODAL JDialog is being displayed, and the cursor is DRAGGED from the JDialog
    *    into and across the parent JFrame, Mouse Enter and Mouse Exit events are given to
    *    the parent JFrame and/or it's child components.  It is my belief that NO such events
    *    should be delivered, that modal dialogs should prevent ANY user interaction with any
    *    component NOT in the JDialog.  Am I crazy?
    *    You can reproduce this simply by running the main() method, then dragging the cursor
    *    from the JDialog into and across the JFrame.
    * 2) When a MODAL JDialog is being displayed, and the cursor is DRAGGED across the JDialog,
    *    Mouse Enter and Mouse Exit events are given to the parent JFrame and/or it's child
    *    components.  This is in addition to the problem described above.
    *    You can reproduce this by dismissing the initial JDialog displayed when the main()
    *    method starts up, clicking on the "Perform Action" button in the JFrame, then dragging
    *    the cursor around the displayed JDialog.
    * The Mouse Enter and Mouse Exit events are reported via System.err.
    public class DragTest
        extends JFrame
        public static void main(final String[] p_args)
            new DragTest();
        public DragTest()
            super("JFrame");
            WindowListener l_windowListener = new WindowAdapter() {
                public void windowClosing(final WindowEvent p_evt)
                    DragTest.this.dispose();
                public void windowClosed(final WindowEvent p_evt)
                    System.exit(0);
            MouseListener l_mouseListener = new MouseAdapter() {
                public void mouseEntered(final MouseEvent p_evt)
                    System.err.println(">>> Mouse Entered: " + ((Component)p_evt.getSource()).getName() );
                public void mouseExited(final MouseEvent p_evt)
                    System.err.println(">>> Mouse Exited: " + ((Component)p_evt.getSource()).getName() );
            JPanel l_panel1 = new JPanel();
            l_panel1.setLayout( new BorderLayout(50,50) );
            l_panel1.setName("JFrame Panel");
            l_panel1.addMouseListener(l_mouseListener);
            JButton l_button = null;
            l_button = new JButton("JFrame North Button");
            l_button.setName(l_button.getText());
            l_button.addMouseListener(l_mouseListener);
            l_panel1.add(l_button, BorderLayout.NORTH);
            l_button = new JButton("JFrame South Button");
            l_button.setName(l_button.getText());
            l_button.addMouseListener(l_mouseListener);
            l_panel1.add(l_button, BorderLayout.SOUTH);
            l_button = new JButton("JFrame East Button");
            l_button.setName(l_button.getText());
            l_button.addMouseListener(l_mouseListener);
            l_panel1.add(l_button, BorderLayout.EAST);
            l_button = new JButton("JFrame West Button");
            l_button.setName(l_button.getText());
            l_button.addMouseListener(l_mouseListener);
            l_panel1.add(l_button, BorderLayout.WEST);
            l_button = new JButton("JFrame Center Button");
            l_button.setName(l_button.getText());
            l_button.addMouseListener(l_mouseListener);
            l_panel1.add(l_button, BorderLayout.CENTER);
            JButton l_actionButton = l_button;
            Container l_contentPane = this.getContentPane();
            l_contentPane.setLayout( new BorderLayout() );
            l_contentPane.add(l_panel1, BorderLayout.NORTH);
            JPanel l_panel2 = new JPanel();
            l_panel2.setName("JDialog Panel");
            l_panel2.addMouseListener(l_mouseListener);
            l_panel2.setLayout( new BorderLayout(50,50) );
            l_panel2.add( new JButton("JDialog North Button"),  BorderLayout.NORTH  );
            l_panel2.add( new JButton("JDialog South Button"),  BorderLayout.SOUTH  );
            l_panel2.add( new JButton("JDialog East Button"),   BorderLayout.EAST   );
            l_panel2.add( new JButton("JDialog West Button"),   BorderLayout.WEST   );
            l_panel2.add( new JButton("JDialog Center Button"), BorderLayout.CENTER );
            final JDialog l_dialog = new JDialog(this, "JDialog", true);
            WindowListener l_windowListener2 = new WindowAdapter() {
                public void windowClosing(WindowEvent p_evt)
                    l_dialog.dispose();
            l_dialog.addWindowListener(l_windowListener2);
            l_dialog.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
            l_dialog.getContentPane().add(l_panel2, BorderLayout.CENTER);
            l_dialog.pack();
            Action l_action = new AbstractAction() {
                { putValue(Action.NAME, "Perform Action (open dialog)"); }
                public void actionPerformed(final ActionEvent p_evt)
                    l_dialog.setVisible(true);
            l_actionButton.setAction(l_action);
            this.addWindowListener(l_windowListener);
            this.pack();
            this.setLocation(100,100);
            this.setVisible(true);
            l_dialog.setVisible(true);
    }(Too bad blank lines are stripped, eh?)
    Thanks in advance for any insights you may be able to provide.
    ---Mark

    I guess we can think of this as one problem. When mouse dragged, JFrame also (Parent) receives events. If i understood correctly, what happens here is, Modal dialog creates its own event pump and Frame will be having its own. See the source code of Dialog's show() method. It uses an interface called Conditional to determine whether to block the events or yield it to parent pump.
    Here is the Conditional code and show method code from java.awt.dialog for reference
    package java.awt;
    * Conditional is used by the EventDispatchThread's message pumps to
    * determine if a given pump should continue to run, or should instead exit
    * and yield control to the parent pump.
    * @version 1.3 02/02/00
    * @author David Mendenhall
    interface Conditional {
        boolean evaluate();
    /////show method
        public void show() {
            if (!isModal()) {
                conditionalShow();
            } else {
                // Set this variable before calling conditionalShow(). That
                // way, if the Dialog is hidden right after being shown, we
                // won't mistakenly block this thread.
                keepBlocking = true;
                if (conditionalShow()) {
                    // We have two mechanisms for blocking: 1. If we're on the
                    // EventDispatchThread, start a new event pump. 2. If we're
                    // on any other thread, call wait() on the treelock.
                    if (Toolkit.getEventQueue().isDispatchThread()) {
                        EventDispatchThread dispatchThread =
                            (EventDispatchThread)Thread.currentThread();
                           * pump events, filter out input events for
                           * component not belong to our modal dialog.
                           * we already disabled other components in native code
                           * but because the event is posted from a different
                           * thread so it's possible that there are some events
                           * for other component already posted in the queue
                           * before we decide do modal show. 
                        dispatchThread.pumpEventsForHierarchy(new Conditional() {
                            public boolean evaluate() {
                                return keepBlocking && windowClosingException == null;
                        }, this);
                    } else {
                        synchronized (getTreeLock()) {
                            while (keepBlocking && windowClosingException == null) {
                                try {
                                    getTreeLock().wait();
                                } catch (InterruptedException e) {
                                    break;
                    if (windowClosingException != null) {
                        windowClosingException.fillInStackTrace();
                        throw windowClosingException;
        }I didn't get exactly what is happening but this may help to think further

  • Double value change event if cursor is set busy (LV2009)

    Hello everybody,
    I just migrated from LV 8.0 to LV 2009 (on linux) and now got problems with a value change event. I want to send a command if a button is pressed and send another one if the button is released. After sending the command I need to wait for an acknowledge from the receiver and to avoid user interaction in between I lock the cursor with "set busy" VI until the acknowledge is received. To see, when the button is pressed or released, I use a value change event. Inside the event structure the cursor is set busy.
    This worked reliable in LV 8.0 but not any more in LV 2009. The button's mechanical action is set to "switch until released" and if I press the button and keep it pressed it is reset to false automatically. The value change event is fired twice instead of only once (see attached vi) and "new value" is one time true and one time false. This doesn't happen if the mechanical action is set to "switch when pressed".
    Does anybody have an explanation or a workaround for this behaviour? Am I doing something wrong or is this a bug in LV? For now I'll just keep the cursor unlocked.
    Thanks for your help.
    Attachments:
    setMouseBusy_01.vi ‏11 KB

    Hi ckis,
    attached you'll find your modified example, it should do the trick now.
    Regards,
    Bernd
    Attachments:
    setMouseBusy_01.vi ‏9 KB

  • Set Busy cursor doesn't change until mouse is moved

    Hello,
    When I use the "Set Busy.vi" to control mouse cursor appearance, it doesn't actually change until the pointer is moved. Similarly, the "Unset Busy.vi" doesn't change appearance until the mouse is moved. Is there a way to fix this?
    Thanks,
    -Dave

    Hi Dave,
    I've tried this and it seems to work okay for me... do you have any example code you can post? Which version of LabView are you using?
    Charlie Rodway
    Test Design Engineer
    Rolls-Royce Controls and Data Services Ltd

  • Can't set "mouse enter"

    I'm trying to set up form buttons for printing and saving that the user must click on to work (triggered by "mouse enter").  Though the "actions" are set to "mouse enter" when I use the form all I have to do is run the mouse over the label and the "print page" will come up or the "save as" page will display.  Any ideas?

    Use "Mouse Up" or "Mouse Down".

  • Set text on textinput enter event

    Hi, is it possible to set the text of a textinput from the enter event?

    When I run the code above, as long as I click in the TextInput control so it has focus, pressing the Enter key sets the text.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
      <mx:Script>
        <![CDATA[
          import mx.events.FlexEvent;
          private function handleEnter(evt:FlexEvent):void{
            evt.target.text = "You pressed the enter key";
        ]]>
      </mx:Script>
      <mx:TextInput enter="handleEnter(event)"/>
    </mx:Application>

  • Mouse Enter/Exit Events

    Hi,
    I've got a question regarding mouse enter/exit events. Specifically, I would like to know why so many mouse enter/exit events are generated. Suppose you stack multiple Panes like this:
    @Override
    public void start(Stage frame) throws Exception {
         Pane root = new Pane();
         frame.setScene(new Scene(root));
         addEnterExitHandlers(root, "root");
         Pane fst = new Pane();
         root.getChildren().add(fst);
         addEnterExitHandlers(fst, "first");
         Pane snd = new Pane();
         fst.getChildren().add(snd);
         addEnterExitHandlers(snd, "second");
         Rectangle rect = new Rectangle(0, 0, 100, 100);
         snd.getChildren().add(rect);
         addEnterExitHandlers(rect, "rect");
         frame.show();
    The addEnterExitHandlers() method simply registers event handlers for MouseEvent.MOUSE_ENTERED_TARGET and MouseEvent.MOUSE_EXITED_TARGET which print the event type's name together with the specified string.
    The resulting output looks like this:
    root MOUSE_ENTERED
    first MOUSE_ENTERED
    root MOUSE_ENTERED_TARGET
    second MOUSE_ENTERED
    first MOUSE_ENTERED_TARGET
    root MOUSE_ENTERED_TARGET
    rect MOUSE_ENTERED
    second MOUSE_ENTERED_TARGET
    first MOUSE_ENTERED_TARGET
    root MOUSE_ENTERED_TARGET
    root MOUSE_EXITED
    first MOUSE_EXITED
    root MOUSE_EXITED_TARGET
    second MOUSE_EXITED
    first MOUSE_EXITED_TARGET
    root MOUSE_EXITED_TARGET
    rect MOUSE_EXITED
    second MOUSE_EXITED_TARGET
    first MOUSE_EXITED_TARGET
    root MOUSE_EXITED_TARGET
    This output is not accurate, because I inserted empty lines to visually group related elements.
    As you can see, a MOUSE_ENTERED event is fired for every node and all parent nodes receive MOUSE_ENTER_TARGET events. I just thought that it would be sufficient to only fire the last group of enter/exit events, respectively, i.e.:
    rect MOUSE_ENTERED
    second MOUSE_ENTERED_TARGET
    first MOUSE_ENTERED_TARGET
    root MOUSE_ENTERED_TARGET
    rect MOUSE_EXITED
    second MOUSE_EXITED_TARGET
    first MOUSE_EXITED_TARGET
    root MOUSE_EXITED_TARGET
    Is there a specific reason for the behavior?
    Best regards,
    Matthias

    Hi Matthias,
    yes, there is a reason for this. In vast majority of use-cases, the entered/exited handlers are added on a node to handle the case when mouse enters/exits the node. The _TARGET variants tell you "this node or some of its children was entered/exited", which is not quite it. So right now, if you want to check that fst was entered, you just do:
    fst.setOnMouseEntered(new EventHandler<MouseEvent>() {
      @Override public void handle(MouseEvent e) {
        // your code
    If we generated only the last group of events as you suggest, you would have to do:
    fst.addEventHandler(MouseEvent.MOUSE_ENTERED_TARGET, new EventHandler<MouseEvent>() {
      @Override public void handle(MouseEvent e) {
        if (e.getTarget() == fst) {
          // your code
    Even if we added the convenience handlers for the _TARGET variants (setOnMouseEnteredTarget), having to always check the target would be pretty annoying.
    Cheers,
    Pavel

  • Mouse down event handling of table control in subvi

    Hello Everyone.......
    I have created a vi which has a table control and xy graph... the function of the vi is to plot the data of two particular column of table into xy-graph after user selects the data from table....  In this vi , I have used mouse down event for selecting data set so that the color of selected row get changed for user reference.......  the vi is working fine..... 
    My problem is that this vi is a part of main vi.. and I want to use this vi as a subvi.... So, in my main vi I have a table control which is connected as input to the subvi...  I come to know that I need to register event for triggering a event in a subvi.......
    (1) How to register Mouse down event of table control which is on Main Vi to trigger mouse down event of table in subvi.... Another Important thing is... how to link every property of table control of subvi to the table control of main vi... so it just act as single control adapting every property like when user selects a particular row its color changes in subvi....so it should be reflected even if user selects a row in main vi... I mean table control of main vi and subvi should be a single control...is it possible?
    I hope I am clear......Thanks ..

    See the modified version of the VI. I use the 'Point to Row Column' method to get the cell that was clicked on - your method also worked using 'Selection Start' but I thought I'd show you an alternative.
    I've used a single event structure to update two table controls - the point is that if you have the references to the controls you can update the control from anywhere. You can also 'register for events' to allow you to register for events from a different VI (again, using the references) that doesn't have the control on the front panel.
    Couple of things about your VI:
    You don't need to put a wait node if you have a timeout on your event structure.
    You don't need the for loop for the columns/rows - if you look at the help for the 'Active Cell' property you can use a value of -2 for the row/column to select all cells in the row/column.
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets
    Attachments:
    Highlight Selected Row in Table Control_lv2009.vi ‏13 KB

  • Creating mouse rollover events on tab selectors in Swing

    Hi,
    I have a jTabbedPane on which I have placed several panels to make tabs.
    Here are the two problems.
    1.How can I control the background color of the tab selector(where the title of the tab resides) when its tab is selected. I have been able to set dynamically the unselected ones.
    2. How can I change the color of the text in the title of the tab when the mouse rollovers the tab selector. When a mouse goes over the selector, the text in the selector needs to change to blue. When the mouse leaves the selector the text color needs to go back to black. I need to capture the event for the selector part only.
    I have been able to do it with buttons but how can I do it with tab selectors?
    Thanks for your help.

    I just did this quick but hopefully it should help you with the mouse events, simply get the rectangles that are associated with the tabs, and dectect when the mouse is inside of one, or not inside of one
    public class TabbedPaneExample {
         JTabbedPane tabbedPane;
         Rectangle r[];
         public TabbedPaneExample() {
              tabbedPane = new JTabbedPane();
              tabbedPane.addTab("PANEL1", new JPanel());
              tabbedPane.addTab("PANEL2", new JPanel());
              tabbedPane.addTab("PANEL3", new JPanel());
              JFrame frame = new JFrame("TabbedExample");
              frame.setSize(400, 400);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(tabbedPane);
              frame.setVisible(true);
              //Get the rectangles associated with each tab
              TabbedPaneUI ui = tabbedPane.getUI();
              r = new  Rectangle[3];
              for (int j = 0; j < 3; j++)
                   r[j] = ui.getTabBounds(tabbedPane, j);
              //add a MouseMotionListener to detect when a mouse enters a tab
              tabbedPane.addMouseMotionListener(
                   new MouseMotionAdapter() {
                        public void mouseMoved(MouseEvent e) {
                             for (int j = 0; j < 3; j++)
                             if (r[j].contains(e.getPoint()))
                                  //put your code for changes here
                                  System.out.println("inside a tab");
         public static void main(String args[]) {
              TabbedPaneExample tp = new TabbedPaneExample();
    }Hope that helps

  • Consuming extra mouse drag events?

    Hi,
    In my mouse drag listener, there is a bit heavy processing that can take slightly long time (doing some real time computation). If I move the mouse fast, then there would be a long pause before processing catch up.
    So my question is that if it is possible to remove some mouse drag events in the queue s.t. my computation only takes on the latest drag event.
    I tried java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().peekEvent(), but it always returns null.
    Anyone could give a hint? Thanks a lot.

    This heavy processing should be done in a new thread and not the event thread. If the event thread is busy processing, it's not going to be able to respond to drag events. Once you do that, it would be easy to set a flag in that thread to notify it to stop processing and start with new values.

  • When-mouse-enter forms 10g

    Hi, everybody.
    I have a problem with forms 10g (web) in any sub-version. The problem is that the events when-mouse (enter, leave, ...) does not seem to get fired.
    Is there anything I can do to solve the problem (a parameter to be set, anything to do in the form).
    Any help will be appreciated,
    Thank you.

    -> Why it is still documented? Will we get back a client server forms?
    I wish! But I am sure it is hopeless. They probably need to leave the when-mouse-enter documentation for backward compatibility -- old forms compiled and running in the Web Forms environment. The traffic would be horrendous. I have WME and WML triggers running, and on some forms, rolling the mouse across the canvas causes a lot of flickering -- item prompts flicker. And then there is the mouse-x,y-pos and when-mouse-move. Those are supported in 6i Client/Server, too. I used it to create a drag and drop functionality. Man, does THAT cause some massive trigger firing!!! Trust me, it would NOT work in a web environment.
    And yes, "Hai" is apparently something like an abbreviation for Hello -- a little more formal and polite than Hi. Its use still puzzles me, but apparently that is the reasoning of those who use it.        ?:|

  • Mouse enter and mouse leave not detected in small controls

    Look at the attached VI. There is a thin boolean with mouse enter and mouse leave events which are not always detected when moving over the control quickly. I'm not sure whether this behavior originates from LV (7.0) or from the way XP handles the mouse movement, but I would definitely call this a bug in the sense that the mouse does "enter" and "leave" the control and the events are not fired.
    My guess is that windows does not register all the points that mouse goes through, but only does so periodically. If it happens that 2 adjacent points are on 2 different sides of the control, LV can't recognize the enter and leave events. But that's just a guess.
    Try to take over the world!
    Attachments:
    event bug1.vi ‏26 KB

    I put together a quick test, but I'm not sure what the results mean.
    Lynn, one of the tests uses windows API (although you can run the other one).
    Shane, sorry, only 7.1 on this PC.
    Message Edited by tst on 07-12-2005 08:38 PM
    Try to take over the world!
    Attachments:
    event bug25.vi ‏40 KB

  • Enter event not triggering for read-only checkbox

    I have some objects in a form that get "locked" when the user signs the form.  I'm not using the digital signatures.  Instead, when the user types their name into the signature text field, a script runs on the change event that makes all of the fields in the form read only.  It also unlocks the fields if the signature is deleted.
    I was worried that we would get a lot of phone calls with users that didn't understand that the form had locked ("Why doesn't this form work?!"), so I added some code to the enter event for all of the fields that would pop up a messagebox to explain to people trying to edit a signed form that the form was locked and that they would need to delete the signature to edit the form.
    This plan works perfect for my text fields and decimal fields.  It does NOT work at all for my checkboxes.  For some reason, the enter event is never triggered for read-only checkboxes.  I don't see any other events that would obviously work for me though.  Any ideas?
    Thanks

    Thanks, those are reasonable suggestions.
    In the first suggestion, I'm unclear about one aspect of how I would accomplish this.  I assume I would allow people to modify fields in the form, but that when they did, a msgbox would pop up that would inform them that, if they continued with this modification to a signed form, the signature would be removed.  I'm all good to that point.  But if they answered that they do not want to continue modifying that field and removing the signature, how can I code it to set the value back to what it was before the change?  Is there some method that will give me access to the value of the field BEFORE the attempted modification?  I went looking for something like $.previousvalue, but found nothing.
    I'd suggest that I could use a two-stage solution, in which I store the previous value on the enter event, and save it just in case they do not want to change the field when prompted by the msgbox, but since the enter event does not exist for checkboxes (my original problem), that seems like it won't work.
    As far as radio button suggestion, I like radio buttons very much except for one fatal flaw: they aren't (as far as I can tell) clearable.  That is a shame.  Clearly some people (like me) want both exclusivity AND clearability.  And we'd like the controls to have an enter event.  But I know I'm demanding   Anyway, as it is, I just end up having to use checkboxes and create a boatload of silly code to make them exclusive.
    Emily

  • Pop Up Text in an applet on mouse over event

    Can anyone help me to design a pop up text message to be displayed in an applet on moving your mouse over a particular control. Plz. Its urgent

    To show a pop-up use javax.swing.Popup. Add a mouse listener to button. When mouse enters the button pop-up shows and when mouse exited the button, pop-up disappears. This pop-up is capable of displaying simple message to any swing component. Sample code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * @author mrityunjoy_saha
    * @version 1.0
    public class AppletWithPopup extends JApplet {
        private Popup popup;
        private JButton button;
        private JLabel message;
        @Override
        public void init() {
            setLayout(new FlowLayout());
            button = new JButton("Hello");
            message = new JLabel("This is a JLabel. It can be any swing component.");
            button.addMouseListener(new MyMouseListener());
            add(button);
        private class MyMouseListener extends MouseAdapter {
            @Override
            public void mouseEntered(MouseEvent e) {
                System.out.println("Mouse entered.");
                PopupFactory factory = PopupFactory.getSharedInstance();
                popup = factory.getPopup(AppletWithPopup.this, message, (int) button.getLocationOnScreen().
                        getX() - 20, (int) button.getLocationOnScreen().getY() + 40);
                //popup = factory.getPopup(AppletWithPopup.this, message, 50, 10);
                popup.show();
            @Override
            public void mouseExited(MouseEvent e) {
                System.out.println("Mouse exited.");
                if (popup != null) {
                    popup.hide();
    }If you are talking about alert box (where some message can be displayed), in above example instead of javax.swing.Popup use javax.swing.JOptionPane. In case you are using JOptionPane, make it visible in mouseEntered() method and hide it in mouseExited() method.
    Thanks,
    Mrityunjoy

Maybe you are looking for

  • VL02N Output type issue.

    Hi, When I execute the tcode VL02N for any output type (ZEU5) for print preview and external mail then it is giving error that "Output could not be issued". I have also checked the config of NACE , it seems to be ok. So what are the other possibiliti

  • Screen display looks fuzzy using xf86-video-intel on a HP Pavilion 23

    Hello, First off I want to say, thank you for Arch! Been using some distros on and off and I think I found my /home! I made a full plunge into Linux a bit ago after some Windows 8.1 issues, switched to Arch and not looking back. Anyways, So far all m

  • Single horizontal line (picture attached)... bad LCD?

    Out of the blue one day, my display suddenly showed a thin 1 pixel line that goes from the left to the right of the screen. It changes color depending on what I've got on the screen. I opened up the computer to make sure everything was clean and dust

  • Daily KDE4 Subversion Packages

    This project is now all but finished after 20 months of daily updates with perhaps only about a dozen days of total downtime. During that time about 5TB of bandwidth was provided from my shared host by the good folks at Dreamhost and at it's peak, in

  • Really don't like new BT vision

    Have recently been upgraded to new BT vision and do not like changes . It is not easier to use TV guide - you cannot just switch on TV you have to negotiate all the categories . Also when listening to radio you get constant advertising of TV programm