Drawning a line where mouse is clicked

Basically, I am doing an application where the user clicks on an icon and draws a line according to the points clicked (using getX & getY). My problem is how to make the application wait for the user to click so that the coordinates are updated accordingly. Can somebody help?
Thank you.

public void mouseClicked(MouseEvent evt1){
         p5.repaint();
            if (linebutton== true){
              ptx1 = evt1.getX(); //source x-coordinate
              pty1 = evt1.getY(); // source y-coordinate
              System.out.print(ptx1 +", " + pty1);
              l2.setText("Please select destination");Now if I put ptx2 = evt1.getX() and pty2 = evt1.getY() after the setText, the same coordinates as before are going to be taken. This is what I mean by the program has to wait for the user to click again. I am confused about this.
Thanks.
Edited by: punkymt1 on Nov 10, 2007 5:58 AM

Similar Messages

  • Load Movieclip where Mouse was clicked

    Hello,
    I got a request to have a "ripple" animation play where the
    mouse was clicked (like the application is in a puddle) and i am
    using AS2 in CS3 and i am not able to get this to work (and really
    surprised i havent ever come across this before). I would like to
    just load an instance of my "ripple_mc" out of the library where
    and when the mouse is clicked.
    i have searched for some tutorials but cant seem to find what
    i am looking for, if anyone can point me to a tutorial or throw
    some code down for me i would really appreciate it
    thanks in advance!

    i put an invisible button in the background and an empty
    movieclip with the instance name "loader_mc" on the stage with the
    following actions on the button:
    on(release){
    loader_mc._x=_xmouse;
    loader_mc._y=_ymouse;
    loader_mc.attachMovie("ripple", "new", 200);
    i would like to eliminate the invisible button and have
    multiple insances of "ripple" able to happen at once...
    the above fla can be downloaded here:
    http://www.michaelsaathoff.com/sample.fla
    thanks!

  • Type anywhere in JTextArea where mouse clicks

    Is it possible to start typing anywhere where the mouse clicks with a JtextArea ? I have an application that needs to allow users to start typing at the position where mouse clicks. Be default, JtextArea starts at (0,0).

    Well, this might not be the cleanest way, but you could create a mouselistener on the TextArea (or subclass it), and
    1) check to see if the clicked position refers to a valid offset in the textArea. If so, you don't really have to do anything, since the basic functionality of the thing should drop the caret in just where you want it. ModelToView() will help you figure out where in the document the mouse clicked.
    2) if not, figure out how many lines down/ tabs over need to be appended to the document to get the cursor where you want it, then insert them
    3) move the cursor to the end of the document.
    this might not be all that clean, especially since fonts vary in width. there are a number of ways you can find out how wide a string is in a given font, though.
    hope that helps

  • Jfreechart line chart mouse click problem

    i need to implement a line chart where users can click on an area of the chart and highlight it, i have serveral questions regarding how to do this:
    i added a mouselistener to the chartpanel, i can get the points with e.getTrigger().getPoint(), but I need the points associated with the graph point, is that possible?
    i also need to highlight an area of the line chart, I have no idea where to begin, will i be able to change the background of a specific range of points?
    help would be appreciated!!

    Hi,
    I have not tested your code, but check these links. This might help.
    http://blogs.adobe.com/flexdoc/2009/07/date_range_selection_for_flex.html
    http://www.stretchmedia.ca/code_examples/chart_range_selection/main.html

  • Adobe Stamps Don't Place Where Mouse Clicks

    Hello,
    My firm is experiencing some issues regarding stamps.  We've created a library of stamps for the employees to use in their documentation.  However, some users are noticing that the stamps don't place where they click.  For instance, a user will select a checkmark stamp, hover the mouse over a box on the pdf file, and click on the box to place the stamp.  The user wants the checkmark to appear inside the box.  However, for some odd reason the stamp appears 20 or so pixels above or below where the user clicks.  It's quite random.  And this occurs on more than one PC type (three different kinds of Toshiba laptops).  It also occurs in both XP and in Windows 7.  Has anyone noticed this?  Does anyone know how to fix this?  I have updated both Adobe and the mouse drivers to see if it makes a difference - it didn't.  Any suggestions would be appreciated!
    Thanks,
    Teresa

    Acrobat is kind of quirky about pasting into the file. Pastes tend to be done at either the top left or the middle of the page, depending on the version of Acrobat. You then have to use the object touchup tool to move the paste to where you want it.

  • Mouse wheel click doesn't open new tabs correctly?

    Since upgrading to FF4, whenever I mouse click a bookmark on my bookmark toolbar, it will open a blank new tab with the URL in the address line, but will not load the page. I have to select the URL in the address line and press enter, or press the green arrow button. Shouldn't web pages automatically load once I mouse wheel click on a bookmark?
    any suggestions?

    Alan McClean has alluded to the cause of this behaviour but I think others would benefit from a full explanation because it doesn't appear to be documented. I might add that Business Objects support were no help at all on this (they suggested I had a problem with my mouse, PC or network which I don't).
    Normal response to a mouse double-click on a document name in InfoView XI3:
    The double-click action performs the default action on the right-click list. This is the option you see in bold when you right-click on a document name. The default action is 'View' document. So when you double-click on the document it opens for viewing.
    In CMC, under Applications>InfoView if you set 'Default viewing action on listing page:' to 'View the latest successful instance of the object' then the double-click behaviour changes:
    The double-click action now tries to open the latest successful instance of a document. I found that any document in my Inbox or any document with instances (e.g. scheduled report) will still open for viewing using the double-click. For any other document the double-click fails silently. I assume this is because there simply isn't a latest instance to open.
    Conclusions:
    1. Don't use the 'View the latest successful instance of the object'. I have reset my CMC setting back to 'View the object'.
    2. I think Business Objects should change the double-click behaviour so that rather than fail silently it opens the document.

  • That line where you can see your bookmarks and stuff is gone..! how do i get it back?

    my laptop is 93.1 % filled up so its working pretty slow.. i was on a website and i tried right clicking (i needed to copy something) and the computer was to slow so it didnt work. (this has happend before). so i tried right clicking a couple of times and before i new it that line where you can see your bookmarks(and other stuff) was gone.! i tried right clicking again to see if i could get it back, but it didnt work. so i tried turning off the computer and it still didnt work. how do i get it back? and if i get it back, will all my bookmarks be gone?

    Firefox 3.6+ versions have a feature to allow the user to hide the Menu bar.
    Hit the '''Alt''' key to temporarily show the Menu bar, then open View > Toolbars and select Menu bar, so it has a check-mark. <br />
    The F10 can also be used on most PC's to temporarily reveal the Menu bar.
    https://support.mozilla.com/en-US/kb/Menu+bar+is+missing

  • Draw a line using mouse

    Hello there:
    I'm trying to draw a line using mouse pointer: My code is:
    public class DrawLine extends JFrame implements MouseListener, MouseMotionListener
        int x0, y0, x1, y1;  
        public DrawLine()
             addMouseListener(this);
             addMouseMotionListener(this);
        public void mouseDragged(MouseEvent e)
             x1 = e.getX();
             y1 = e.getY();
             repaint();
        public void mouseMoved(MouseEvent e) { }
        public void mouseClicked(MouseEvent e){ }
        public void mouseEntered(MouseEvent e) { }
        public void mouseExited (MouseEvent e) { }
        public void mousePressed(MouseEvent e)
              x0 = e.getX();
              y0 = e.getY();           
        public void mouseReleased(MouseEvent e)
              x1 = e.getX();
              y1 = e.getY();
       public void paint(Graphics g)
                 g.setColor(Color.BLACK);
              g.drawLine(x0, y0, x1, y1);
        public static void main(String[] argv)
             DrawLine dr=new DrawLine("Test");
             dr.setVisible(true);
             dr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }when mouse is dragged, multiple lines are being drawn....
    could you else please tell me what should I've to do???
    thanks n regards...
    Dev

    You can implement the listeners on any class, even one that (implicitly) extends Object. What matters is that the listener is added to the component that needs to use it.
    That said, why do you want to extend JFrame? Are you adding functionality to the JFrame to justify extending the JFC class? Note that extending JFrame allows the users of your class to access the functionality of a JFrame, is that really indicated here?
    one class that extends JFrame, and one can draw a line on JLabel, embedded within JFrame!So you still have to override paintComponent of the JLabel, which implies using an anonymous inner class.
    Starting with the example already posted, that would be:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.SwingUtilities;
    public class DrawLineTest
        implements MouseListener, MouseMotionListener {
      JLabel label;
      int x0, y0, x1, y1;
      private void makeUI() {
        JFrame frame = new JFrame("DrawLineTest");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        label = new JLabel("FFFF") {
          public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.BLACK);
            g.drawLine(x0, y0, x1, y1);
        label.setPreferredSize(new Dimension(500, 500));
        label.addMouseListener(this);
        label.addMouseMotionListener(this);
        frame.add(label);
        frame.pack();
        frame.setVisible(true);
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            new DrawLineTest().makeUI();
      public void mousePressed(MouseEvent e) {
        x0 = e.getX();
        y0 = e.getY();      
      public void mouseReleased(MouseEvent e) {
        x1 = e.getX();
        y1 = e.getY();
      public void mouseDragged(MouseEvent e) {
        x1 = e.getX();
        y1 = e.getY();
        label.repaint();
      public void mouseMoved(MouseEvent e) { }
      public void mouseClicked(MouseEvent e){ }
      public void mouseEntered(MouseEvent e) { }
      public void mouseExited (MouseEvent e) { }
    }Better spend more time with the tutorials, there's a separate section on writing event listeners.
    db

  • FRM-40735 when mouse double click trigger raised unhandled exceptiORA-01722

    I am using Forms 10g.
    i am writting a procedure in When mouse double click trigger that will display all the values available for ip address from this procedure.
    The procedure is
    DECLARE
    CURSOR cr
    IS
    SELECT LEVEL NUM
    FROM DUAL
    CONNECT BY LEVEL<=(Select max_range from t_ip_address_dtl where category_name=:t_item_cpu.category and block_name =:block_head.block)
    MINUS
    SELECT TO_NUMBER(SUBSTR(IP_address, 12))
    FROM T_item_cpu;
    abc number(4);
    abc1 number(4):=null;
    BEGIN
    FOR rec IN cr LOOP
         abc1 := abc1 || ',' || rec.num;
    END LOOP;
    Message('You can use between these nos: '||abc1);
    Message('You can use between these nos: '||abc1);
    END;
    It is showing this error :-

    Yes bye mistakly i posted ,, due to internet problem..

  • Mighty Mouse Right Click

    Hi,
    I have a Mighty Wireless Mouse, and a Wireless Keyboard.
    1.) If I would like to keep the track wheel button as the dashboard, can I create a secondary mouse button, or a right click? I know Ctrl-click will be a right click most of the time, but I have a game, where a right click is very useful, but Ctrl-click doesn't work.
    2.) Is the main part of the Mighty Mouse just one button, or can I set a primary and secondary on the left and right half of the mouse.
    Any advise?
    ~Christoph

    Right. I am using the track-wheel button as dashboard, which I would like to keep. The secondary button doesn't seem to work at first. I told system prefs to put the right button as the secondary button, but after a restart, it is now working. I don't know why I had to restart, but it is now working.
    Thanks for the help, though
    Sorry none of you get the nice, green star
    ~Christoph

  • Submenu, mouse right click info are missing

    submenu, mouse right click info are missing

    Missing from where? In what application?
    Can you describe what you are trying to do?

  • Where do I click to see my music videos?

    Where do I click in the "new improved" iTunes window to see my music videos?
    I click on the Library > Music in the (restored) left sidebar, and then I have a selection of buttons above the titles: Songs, Albums, Artists, Genres, Videos
    ... but none of my music videos are shown there. Where did they go in iTunes?

    David,
    you should see a symbol on the right side of the calendar name (a dot with curved lines, similar to those at the speaker symbol).
    Right click/ctrl-click on the symbol and choose "Show calendar on .Mac". This should launch your browser with the necessary URL which yo can now bookmark.

  • The mouse right-click (to copy-paste) menu does not work correctly.

    The mouse right-click copy-paste menu often fails in Firefox 4. If I highlight something to copy and then use the mouse to right-click on it, the menu will appear down and to the right. Second, the highlighted command (i.e. copy, paste, etc) will be two steps beneath the mouse pointer. Third, if one chooses "copy" for example, your highlighted text might or might not (usually Not) be copied. This works as expected (perfectly) on this Firefox site, but fails on all other web pages. Note: This is a "company computer" where I am not an administrator.

    I am the admin on my PC, and I am not able to select the copy page after I have highlighted an area. I can if a link select copy link, but in short no more copy paste feature on this new Firefox.

  • Mouse/mousepad clicks and taps not always recognised.

    I've noticed recently that I have an issue with both my magic mouse and my mouse pad, effecting both left and right clicks on the mouse and mousepad, and taps on the mousepad too. I've noticed the issue across many of the main applications I use, such as Mail, Adium, but is more apparent in Safari, or other browsers, where mouse clicking is used more.
    The issue is that not all mouse/mousepad clicks and taps are recognised on the first click, even when the mouse icon changes with link rollovers etc. It is more apparent when changing between application windows or after opening a new window/tab/page in Safari. Closing/minimising windows is effected etc, as is selecting items on the Dock. In all cases when this happens, a second click/tap always works.
    I'm guessing that it is a problem with Finder, maybe caused by another program or something. It's really annoying actually!
    Any ideas?

    ChloeHeather wrote:
    The mouse has fresh batteries is fully connected to the computer and the cursor moves as normal. 
    But when I click (either right or left) the computer ignores me. 
    I can only assume that:
    * mouse is somehow broken - although clicks feel okay, or
    * computer is somehow broken and can't tell clicks are being made
    So, what do I do?
    Buy a new mouse for £50?  Or adjust something in the computer?   No idea which is best, and HP won't help as the computer is just over one year old. 
    Try moving the USB receiver closer.
    You could also try uninstalling and reinstalling the drivers from Device Manager, then the original driver then the updated driver from your Update page on the HP Website.
    Also try running a virus scan using Malwarebytes if you can, Malwarebytes Home Page
    I have more HP devices than you'd expect.
    1 HP TouchPad 32 GB with Android
    2 HP Touchsmarts (310-1000z and IQ527)
    2 HP Printers (J6480 and J5750)
    1 Laptop (HP DV6253CL)
    Have at least some experience in each of those devices, and i'll do my best to help you.
    Kudos if I helped!

  • How convert to mobile...eg apply touch where as exist click event(mainly for javascript or jQuery, w

    I built a tinyStickyNotes App and works in PC browsers, how convert to mobile...eg apply touch where as exist click event(mainly for javascript or jQuery, well needed develop two versions of my App  mobi/PC?)?
    Really needed this or phone gap do the job?
    a phone gap book includes what needed change (in this case) or look for a ...?... Book?
    Also, not needed registered as phone gap user 9.99/mo if I am adobe creative cloud member, that's correct? yes correct / no needed
    Cloud file drive(file explorer win or mac), may installed and in my computers not have creative cloud apps on them?

    absolutely. Being that there will be no touch events via the mouse and mouse events via the touch screen, the two should not conflict with one another.  In the future css specifications, there will be something called touch points which will handle the events no matter the input.

Maybe you are looking for

  • Oracle BPM custom report

    hi i'm new to this BPM product. how can i create a custom report with interface like BAM ? and i also want to add few combobox / input for the user to fill in and then can impact the report result. e.g : i have a credit approve process. at the begin

  • Chram 4 system Landscape

    Dear Friends, One of our syetem has 4 system landscape and we have activated the same for chram process Dev -> QA -> Pre-PRD -> PRD Dev has the system Role as Source system QA and Pre-PRD has the system role Target system PRD has the system rolePRodu

  • Cannot create a Smart Album

    when I select "New Smart Album" nothing happens. No error message, nothing. I can create anything else, the option isn't greyed out. Not sure why this is happening or how to correct. Thanks

  • Need help asap! New to Audition and its freezing. work is not saved!

    So I've edited an audio file and after adding an envelope it's like the program is freezing but not completely. I can use keyboard shortcuts, but I can't click on anything. When I try to click on File or Edit at the top menu, I hear this stupid littl

  • SCCM client re-assign

    Hi, We have two primary SCCM 2007 sites managing over 7K clients. for one of primary server performance issue, we want all clients to be managed by single primary site. By moving boundaries from ABC to XYZ site, do you think that client will assign t