Slow drawing

Discussion in 'Java' started by AHM, May 12, 2004.

  1. AHM

    AHM Guest

    Hi

    I've got a problem with the code below and I'm hoping someone can help
    me optimize it. What I want is to draw a horizontal line where the mouse
    cursor is located in the panel. Unfortunately the drawing is a bit slow
    resulting in the line being a little delayed as to where the mouse
    cursor is. Can anyone help me sort this out?

    [TestApplet.java]

    import java.applet.Applet;
    import java.awt.*;

    public class TestApplet extends Applet {
    TestPanel testPanel = new TestPanel();

    public void init() {
    this.setLayout(new BorderLayout());
    add(testPanel, BorderLayout.CENTER);
    }
    }

    [TestPanel.java]

    import java.awt.*;
    import java.awt.event.MouseMotionListener;
    import java.awt.event.MouseEvent;

    public class TestPanel extends Panel implements MouseMotionListener {
    Graphics graphics;
    Image image;
    Dimension dimension;

    int currentMousePositionY;

    TestPanel() {
    this.addMouseMotionListener(this);
    this.setBackground(Color.white);
    }

    public Dimension getPreferredSize() {
    return new Dimension(250, 300);
    }
     
    AHM, May 12, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    661
    Kevin Spencer
    Jan 9, 2006
  2. Replies:
    3
    Views:
    3,054
  3. AHM

    Slow drawing

    AHM, May 12, 2004, in forum: Java
    Replies:
    2
    Views:
    634
    John C. Bollinger
    May 12, 2004
  4. phil

    Canvas drawing slow

    phil, May 2, 2005, in forum: Python
    Replies:
    0
    Views:
    328
  5. defn noob
    Replies:
    1
    Views:
    415
    Mark Space
    Jun 28, 2008
Loading...

Share This Page