Results 1 to 5 of 5
  1. #1
    yemista is offline Member
    Join Date
    Oct 2011
    Posts
    41
    Rep Power
    0

    Default java event handling is too slow

    Is there a better way, a more low level direct way, to catch mouse events than an event listener? I am trying to create a paint program in java, but the symptom i am having is that when you move the mouse too fast over the component, there are gaps in the line you are trying to draw. how its supposed to work is that when you click and move your mouse around, there should be a black line everywhere under the mouse, but instead there are gaps everywhere. to see what i am talking about, check out this webpage: Applet Tutorial: Painting and try painting on one of the applets. Same exact behavior that I have when you move the mouse too fast. Is there any way to directly read from the mouse driver? I know this is java, but there must be a solution to this problem.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: java event handling is too slow

    Any paint program would work this poorly if written to draw dots. Instead of drawing dots, why not simply connect lines? This is how many other paint programs work.

  3. #3
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: java event handling is too slow

    In my understanding it is not the Java event handling that is slow, but more on how the program draw image / line that make it looks like to be slow. The program should be able to make a continue line by drawing from the previous position of your mouse to the latest position it point to. The tutorial that you've shown might not be a perfect example so it give you the impression that event handling in Java is slow. Try to Google for some more paint brush example in Java.

  4. #4
    yemista is offline Member
    Join Date
    Oct 2011
    Posts
    41
    Rep Power
    0

    Default Re: java event handling is too slow

    Ok, the trick was to draw a line between two points, that way if you move the mouse too fast and miss mouse events, youll still get a continuous line. thanks for the help!

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: java event handling is too slow

    You're quite welcome. Though note that sometimes you want to draw the discrete dots or blobs, as some painting programs will do if you are say spray painting, or something similar.

Similar Threads

  1. Java 1.0 event handling mechanism....
    By Cosmos in forum Advanced Java
    Replies: 2
    Last Post: 10-23-2011, 09:58 PM
  2. Event handling... help?
    By kevzspeare in forum New To Java
    Replies: 2
    Last Post: 04-04-2009, 09:46 PM
  3. Event handling in JSF
    By java08 in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 03-24-2009, 07:42 AM
  4. rmi and event handling
    By darkhorse in forum Advanced Java
    Replies: 0
    Last Post: 03-15-2009, 09:20 AM
  5. Event Handling
    By luisarca in forum Sun Java Wireless Toolkit
    Replies: 5
    Last Post: 05-07-2007, 07:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •