actualy LinkedList is neither abstract nor an interface!
LinkedList is one of the implementations of the List interface (ArrayList and Vector are some of the other implementations)
java.util.List but back to the rectangle problem:
you need to:
- create a Object (or reuse the Rectangle class of
java) that represents a rectangle
- keep a list of rectangles that you need to draw
- everytime you need to draw your rectangles, you would loop over this list and draw each rectangle
- then, as Keith sugested, look at some GUI concepts such as MouseEvents, MouseListener, MouseMotionListener which will help you to capture mouseclicks, mouse dragging and so on.
- find a way how user can interact with your GUI so he can specify the dimensions of the rectangle (e.g. first click set x1/y1, second click sets x2/y2) and when the rectangle is defined then you create a rectangle object and add it to the List of rectangles.
- find a way how user can select/drag rectangles (e.g. user clicks, you loop the list of existing rectangles to find the rectangle he clicked, then draw it in a different color and allow dragging.... this is a little bit more complex since there could be several rectangles at the same position and so on)
pascal
[ May 01, 2006: Message edited by: pascal betz ]