I want to detect mouse click on JTextFild

I want do some opration on JTextField when
Click on JextField how should i do that
please tell me
Rahul

Quit cluttering the forum by posting your question 4 times.
You've already been given the answer in one of your posting, but you've you've made so many postings on the same topic that you can't even find your original posting.

Similar Messages

  • Detecting mouse clicks in editable cell of JTable

    Hi everyone :)
    I thought that this question might have been asked before, but I have searched the forums extensively and have not been able to find the solution.
    What I want to achieve is to detect single and double mouse clicks on JTable cells (that are editable).
    For example, I have a JTable and there exists within it an editable cell. If the user clicks on it once then that cell goes into edit mode, and the user can type directly into the cell. I have already successfully implemented this.
    However, what I also want to do is detect a double-click so that I can pop up a dilaog that shows a list of default values that the user can select.
    So here is what I want;
    1. User clicks on the cell once.
    2. Cell moves into edit mode.
    3. If the user clicks again within a certain time interval then cancel edit mode and pop up a dialog containing values that the user can select from.
    I think that to do this I need to be able to detect mouse clicks on the cell that is currently being edited. So far I have been unable to discover how this is done. I have even tried extending JTextField to get what I want, but with no luck.
    Any help would be greatly appreciated.
    Kind regards,
    Ben Deany

    Thanks for the reply.
    Unfortunately, it is not possible to call 'AddMouseListener()' on a cell editor. You are only able to call 'addCellEditorListener()' and that only allows two events to the broadcast (edit cancel, and edit stop).
    Ben

  • How to detect mouse clicks on desktop?

    Hi All,
    I need to detect mouse clicks on the desktop and find out mouse position on the screen. How to listen to mouse events if I don't have any swing components like containers, panels, windows, etc? All things like "addMouseListener" are supposed to be with such components. But my program is running in the background and it doesn't have any graphical interfaces. So, I need to detect if a mouse button is pressed at any position on the screen.
    Thanks for any help!

    Why? What program feature do you intend to offer, by knowing what a user clicks on (besides the application itself).Hi, well 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 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, once done, I have to take an screenshot...so on.
    How can I do that? Can anybody give me a hint? Thanks in advance.

  • 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.

  • Detecting mouse click on a line

    I'm learning making GUI apps in Java.
    Here is my problem. Suppose I draw a line on a JPanel. If I want to find out if the line is clicked or not, what is the best way to do it?
    I did some research, looked at API. If I suppose my line is Line2D, then since its a line it doesn't have an area, so its contains method always returns false (..from API). So i dig around some more and came up with the solution of getting the shape from the stroke and calling its contains method.
    This is a code for what i mean..
    private Line2D.Double testLine;
    //mouse clicked event
    public void mouseClicked(MouseEvent e) {
            int x = e.getX();
            int y = e.getY();
            BasicStroke stroke = new BasicStroke(4);
            Shape testShape = stroke.createStrokedShape(testLine);
            if(testShape.contains(x,y)){
                System.out.println("this will be printed if clicked on line");
        }Well, the above solution works fine.
    Is it the right way of doing it or is there a better way around for this?
    Any help will be appreciated.
    Thanks.

    When trying to test if a line was pressed I usually test if the distance between the mouse coordinates and the line is smaller than some constant (usually 5 pixels).
    For this you have to write your own code to calculate the distance between a point and a line.

  • How to detect mouse click event?

    Hello,
    I would like to have a vi to detect left, right and no mouse click. I mean that in the vi attached, Button2 should be 0 (no click), 1 (left c.) or 2 (right c.) depending on the event occured in i-1. cycle. My vi is the modyfied version of the one found here:
    http://www.ni.com/example/27663/en/
    Sometimes it works fine, but another time nothing happens when I click.
    I think the main problem is with the execution times at the for loop and event structure.
    Could you help me how to deal with the problem?
    Thanks you!
    Attachments:
    mouse1.vi ‏12 KB

    Hi VampireEmpire,
    Your For loop iterates twice. If an event occures during first iteration everything is fine - Button 2 refreshes during second iteration. But what happens when an event occures during second iteration? Does Button 2 have a possibility to refresh? 
    1. Do you see the problem now?
    2. And if you do - do you really need For loop? I would suggest you trying removing it and connecting shift register to the while loop.
    Bluesheep

  • Detect mouse click in FlashPlayer ActiveX

    I'm hosting the FlashPlayer ActiveX control (Flash9f.ocx) in
    a VB 6 application. The OCX exposes the following events:
    FlashCall, OnProgress, OnReadyStateChange and FSCommand. It does
    not expose the traditional Click, MouseUp or MouseDown events (for
    example) so is there a way to receive mouse click events in the
    hosted application?
    Also, I am unable to find any documentation on the FlashCall
    event. Any ideas what it is and how it works?
    Thanks to any and all.

    jList1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jList1_mouseClicked(e);
    public void jList1_mouseClicked(MouseEvent e){
    JOptionPane.showMessageDialog(null,"test"); }
    I got it. Thanks.
    I forgot to add the MouseListener initally

  • 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

  • Figuring out where a mouse click is under an image

    I want to create a JFrame (or JPanel) where the whole area is one big gif (or icon etc) and I want to make some areas of this panel react to mouse clicks and other areas display messages.
    There are two ways that I can think of doing this.
    The first is that I figure out the x and y coordinates of each area and check to see if each mouse click is within that area.
    The second way is to see if I can figure out how to put something like transparent JButtons over the areas that I want to accept mouse clicks (all the areas will be rectangular) and just do what JButtons do normally.
    The second way sounds easier but I don't know how to do that.
    Does anyone have opinions on which way I should do it?
    Thanks

    To me the first method sounds eaiser.
    A third possible idea? Add a bunch of JPanels to the frame and have split the image into several pieces that are painted by each JPanel. Then use a mouse listener to detect clicks. (Seems easier than trying to make JButton transparent and placing it at the correct point).

  • Mouse click on graph without event handling

    Is there a way to detect mouse click on a graph without the event handling? My base version of LabVIEW does not have event handling features.
    Thanks,
    Ryan
    Solved!
    Go to Solution.

    Leaving out the Event Structure seems like cruel and unusual punishment.  My scorn is divided about 80/20 between NI for selling it and whoever tried to save a few bucks by buying it and then sticking it to you to workaround.  Perhaps you are a student in which case you are free labor and it is all good.
    Maybe your boss is a purist and dislikes Event Structures because they break the dataflow paradigm.  The alternative is of course polling, and in this case you have plenty of data flowing!  Unfortunately 99.9% of it is worthless.  Here is a little example in LV8.2 (don't know your version) that uses polling to check on the mouse button.  I only added a simple check for the button being pressed, if you want to know click (down/up) you can add a shift register and look for transitions in the button.  I do check that the front panel is up front, otherwise it will still register clicks even though you may be surfing the web.
    Hopefully everything is in the base package.
    Attachments:
    MouseClickNoEvent.vi ‏26 KB

  • Mouse Clicks in Captivate

    I have a number of captivate animations that have mouse
    clicks. However even though I have set and checked all mouse clicks
    the 'click' audio does not consistently work. Is there a trick to
    setting the audio click.
    I am using Captivate V2.0.0 build 1177

    Hi Mike Wald and welcome to our community
    Sorry, but I'm a bit confused by your post. Which is true?
    Are you saying that a mouse click is heard and you don't want
    it to be? If so, take a look at the links below:
    Link One
    Link
    Two
    Or is it that you
    want to hear mouse clicks and are not? In this case, other
    than checking each mouse movement, I'm a bit stumped.
    Cheers... Rick

  • Mouse click in JTable

    Hi All,
    I want to force mouse click when right clicking on a JTable. I mean when the right click is done in the mouse, the left click should be forced. I have a JTable with some values in it. I want to select the particular column in the table when right click mouse action. How can I do it?
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class TableDemo extends JFrame
        private JTable table;
        private JScrollPane jsp;
        private JPanel jp;
        public TableDemo()
            initComponents();
        private void initComponents()
            jp = new JPanel();
            String columnNames[] = { "Column 1", "Column 2", "Column 3" };
            String dataValues[][] =
                { "12", "234", "67" },
                { "-123", "43", "853" },
                { "93", "89.2", "109" },
                { "279", "9033", "3092" }
            table = new JTable(dataValues, columnNames);
            jsp = new JScrollPane(table);
            jsp.setViewportView(table);
            jp.add(jsp);
            table.addMouseListener(new MouseAdapter() {
                public void mouseClicked(MouseEvent evt) {
                    if(evt.getButton() == 3) {
                        System.out.println("Right Click........");
                        // Mouse left click should be forced here to select the row.
                    if(evt.getButton() == 1) {
                        System.out.println("Mouse LEFT CLICK FORCED.....");
            getContentPane().add(jp);
            pack();
            setVisible(true);
        public static void main(String args[])
            new TableDemo();
    }

    There may be a better way, but you could just use java.awt.Robot to perform the left click. I've changed your code around a bit: it shouldn't extend JFrame as it is in no way a special type of JFrame. And a GUI should always be launched on the EDT.**import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ForceLeftClick {
       private JTable table;
       private void makeUI() {
          String columnNames[] = {"Column 1", "Column 2", "Column 3"};
          String dataValues[][] = {
             {"12", "234", "67"},
             {"-123", "43", "853"},
             {"93", "89.2", "109"},
             {"279", "9033", "3092"}
          table = new JTable(dataValues, columnNames);
          JScrollPane scrollPane = new JScrollPane(table);
          scrollPane.setViewportView(table);
          table.addMouseListener(new MouseAdapter() {
             @Override
             public void mouseClicked(final MouseEvent evt) {
                if (evt.getButton() == MouseEvent.BUTTON3) {
                   System.out.println("Right Click........");
                   // Mouse left click should be forced here to select the row.
                   //final Point point = evt.getLocationOnScreen();
                   SwingUtilities.invokeLater(new Runnable() {
                      @Override
                      public void run() {
                         try {
                            Robot robot = new Robot();
                            //robot.mouseMove(point.x, point.y);
                            robot.mousePress(InputEvent.BUTTON1_MASK);
                            robot.mouseRelease(InputEvent.BUTTON1_MASK);
                         } catch (AWTException ex) {
                            ex.printStackTrace();
                if (evt.getButton() == MouseEvent.BUTTON1) {
                   System.out.println("Mouse LEFT CLICK FORCED.....");
          JFrame frame = new JFrame();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.add(scrollPane);
          frame.pack();
          frame.setVisible(true);
       public static void main(String args[]) {
          SwingUtilities.invokeLater(new Runnable() {
             @Override
             public void run() {
                new ForceLeftClick().makeUI();
    }If there are issues of Robot clicking in the wrong location because the user moves the mouse before the robot does its stuff (not likely, but..), uncomment the two commented lines.
    db
    **edit And always use constant fields by name, not magic numbers. MouseEvent.BUTTON1, not 1. That keeps your code implementation independent.
    Edited by: Darryl.Burke

  • Pressing cntrl+left mouse click doesn't select multiple rows.

    Hi,
    I've got this problem after i migrated my form from 6i to 10g.
    In 6i version, cntrl+left mouse click used to work in order to select multiple rows on the screen. But, it's not working in 10g.
    Instead, Shit + left mouse click is working to select multiple rows in 10g.
    Please can someone help me out with this. I want cntrl + left mouse click to work.
    Any help will be appreciated.
    Regards
    Navnit

    Hi Pradeep,
    Thanks for your reply.
    Do you mean fmrweb.res file?
    This is the content of my res file
    9 : 0 : "Tab" : 1 : "Next Field"
    9 : 1 : "Shift+Tab" : 2 : "Previous Field"
    116 : 0 : "F5" : 3 : "Clear Field"
    38 : 0 : "Up" : 6 : "Up"
    40 : 0 : "Down" : 7 : "Down"
    33 : 0 : "PageUp" : 12 : "Scroll Up"
    34 : 0 : "PageDown" : 13 : "Scroll Down"
    69 : 2 : "Ctrl+E" : 22 : "Edit"
    10 : 0 : "Return" : 27 : "Return"
    76 : 2 : "Ctrl+L" : 29 : "List of Values"
    115 : 0 : "F4" : 32 : "Exit"
    75 : 2 : "Ctrl+K" : 35 : "Show Keys"
    83 : 2 : "Ctrl+S" : 36 : "Commit"
    118 : 1 : "Shift+F7" : 61 : "Next Primary Key"
    117 : 0 : "F6" : 62 : "Clear Record"
    38 : 2 : "Ctrl+Up" : 63 : "Delete Record"
    117 : 1 : "Shift+F6" : 64 : "Duplicate Record"
    40 : 2 : "Ctrl+Down" : 65 : "Insert Record"
    119 : 1 : "Shift+F8" : 66 : "Next Set of Records"
    1005 : 0 : "Down" : 67 : "Next Record"
    1004 : 0 : "Up" : 68 : "Previous Record"
    118 : 0 : "F7" : 69 : "Clear Block"
    66 : 2 : "Ctrl+B" : 70 : "Block Menu"
    34 : 1 : "Shift+PageDown" : 71 : "Next Block"
    33 : 1 : "Shift+PageUp" : 72 : "Previous Block"
    116 : 1 : "Shift+F5" : 73 : "Duplicate Field"
    119 : 0 : "F8" : 74 : "Clear Form"
    122 : 0 : "F11" : 76 : "Enter Query"
    122 : 2 : "Ctrl+F11" : 77 : "Execute Query"
    69 : 3 : "Shift+Ctrl+E" : 78 : "Display Error"
    80 : 2 : "Ctrl+P" : 79 : "Print"
    123 : 0 : "F12" : 80 : "Count Query"
    85 : 2 : "Ctrl+U" : 81 : "Update Record"
    121 : 3 : "Shift+Ctrl+F10" : 82 : "Function 0"
    112 : 3 : "Shift+Ctrl+F1" : 83 : "Function 1"
    113 : 3 : "Shift+Ctrl+F2" : 84 : "Function 2"
    114 : 3 : "Shift+Ctrl+F3" : 85 : "Function 3"
    115 : 3 : "Shift+Ctrl+F4" : 86 : "Function 4"
    116 : 3 : "Shift+Ctrl+F5" : 87 : "Function 5"
    117 : 3 : "Shift+Ctrl+F6" : 88 : "Function 6"
    118 : 3 : "Shift+Ctrl+F7" : 89 : "Function 7"
    119 : 3 : "Shift+Ctrl+F8" : 90 : "Function 8"
    120 : 3 : "Shift+Ctrl+F9" : 91 : "Function 9"
    113 : 0 : "F2" : 95 : "List Tab Pages"
    72 : 2 : "Ctrl+H" : 30 : "Help"
    112 : 0 : "F1" : 30 : "Help"
    I don't know what value should i enter for cntrl + left mouse click ?
    Even for shift + left mouse click, row is not there but it's working.
    Please tell if you know what row should i enter for cntrl + left mouse click in order for it to select mutliple rows?
    Regards
    Navnit

  • How to disable mouse click ??

    hi ,
    i have a form in which i have a block abc in this there are 5 items say a,b,c,d,e
    suppose my cursor is in item field 'a' there i have entered some value then i go to item field b and entered some value and then i go to field c without any enter or tab but with the help of mouse only. there i want to put a trigger on block level ( on-mouse-click) that whenever anyone tries to move from the current field to another field with the help of mouse then the cursor should be moved to previous item automatically that is item 'b'. in breif i want to disable mouse click from moving one field to another.
    on-mouse-click i can store system.current_item i.e 'a' but not able to store previous field i.e 'b'.
    please help....
    thanks
    Edited by: Hi FRNzzz!! on Feb 23, 2010 7:10 PM

    Hello,
    Try to set the mouse navigation limit form-level property to item when you want to disable the mouse.
    Francois

  • How to unbind mouse click 4&5 on firefox, because I use taht for an other software ?

    I want to unbind mouse click 4 & 5 on firefox.
    Because I use this buttons fort "Mumlble (chatvocal)"
    When I click on my button 4 or 5 of my mouse, firefox goes to the previous or next page. Can you help me please ?
    (I want not change my bind on mumble, it for that I want delete the button 4 & 5 of my mouse on firefox)

    Try http://www.highrez.co.uk/downloads/XMouseButtonControl.htm - X-Mouse Button Control

Maybe you are looking for

  • Nokia N96 - A long review!

    The Nokia N96 Long Review by Jupstejuho v. 1 (Please notice that this is the first published version so I will be making this much longer a bit later if you just want me to do so) In this case I have only reviewed the phone's main software things, no

  • How to access a xml file stored in a jar file

    Hi all, We have a java web start app that uses the jasper reports libraries to produce pdf reports. When running and testing from the ide the prog works ok. However when we place the jar on the web server and run the web start app the prog complains

  • Report on tcode kka2

    Dear All, As per requirement of user I was asked to develop a report to get the values of Actual revenue, Actual costs, revenue affecting net income (RANI) etc., the selection screen is based on for a particular period for different projects. I asked

  • How can I step backwards when in shuffle mode, without reshuffling?

    How can I step backwards though my previously played songs when in shuffle mode, without reshuffling the order of the songs?

  • Connection is refused

    I install Oracle 10G XE Edition on my system fine (Windows XP Home Edition w/ SP1, etc etc). However, when I go to the database homepage I get this connection, even though my port 8080 is open: "The connection was refused when attempting to contact 1