Results 1 to 2 of 2
  1. #1
    StressaJune is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default Simple Paint program question

    I'm trying to make a simple paint program. I already have the canvas and the menubar, and I have the options for rectangles and ovals.

    Right now I check the mouse and get x,y position data and then draw the corresponding rectangle or oval, depending on which shape is selected.

    But the problem is, I want to be able to select my rectangle or oval shape and then move it around the canvas.

    What would I need to do in order to do that? Can anyone give me examples?

    I would post my code but it's pretty long. :eek:

  2. #2
    paul pasciak is offline Senior Member
    Join Date
    Jul 2008
    Posts
    125
    Rep Power
    0

    Default

    Java Code:
    Right now I check the mouse and get x,y position data
    and then draw the corresponding rectangle or oval,
    depending on which shape is selected.
    From this, here are some things I know you know.

    You know how to make the canvas respond to the mouse.
    You know how to record mouse coordinates for each shape.

    You should know that you can extend the data structure
    that contains the above data to include:

    Shape color
    Bounding rectangle
    Centroid
    number id
    name
    selectedToDrag
    and any other data that may or may not be useful.

    My first thought was that you should add a bounding box
    to your data structure. When your mouse movement
    falls within a box, select that object, and create an
    algorithm that modifies that object's x y values per
    the mouse movement, or arrow keys.

    I've done this many times, but I can't afford to spend
    any more time on the details beyond this.

Similar Threads

  1. Simple Question
    By barusk in forum Networking
    Replies: 13
    Last Post: 03-04-2009, 07:33 PM
  2. A simple List question
    By right2001 in forum New To Java
    Replies: 2
    Last Post: 02-16-2009, 03:37 AM
  3. Replies: 3
    Last Post: 12-31-2008, 05:57 AM
  4. Simple Method Question
    By Froz3n777 in forum New To Java
    Replies: 2
    Last Post: 02-13-2008, 02:39 AM
  5. Probably a really simple question...
    By ibanez270dx in forum New To Java
    Replies: 0
    Last Post: 11-16-2007, 01:27 AM

Posting Permissions

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