Hello, I am a beginner in Java. I am looking for 2 weeks and I despair.
I have a code to resize a single rectangle. I would like to display and resize multiple rectangles independently and according to my research on the net, the best way is to use an arraylist. So I modified the code in this sense, except ...when I run the code, the rectangles appear good but impossible to resize.
I think the problem comes from mousePressed, Released, Dragged and Moved methods. When I use the mouse to resize the rectangle, nothing happens. The code does not interact with the arraylist, and therefore with rectangles it "contains". Resizing is my main class, the MouseAdapter is in the Resizer class (below).

Java Code:
        Resizing component;  
        boolean dragging = false;  
        // Give user some leeway for selections.  
        final int PROX_DIST = 3;  
        Path2D.Double selectedPath;  
      
        public Resizer(Resizing rz) {  
            component = rz;  
            component.addMouseListener(this);  
            component.addMouseMotionListener(this);  
        }  
        public void mousePressed(MouseEvent e) {  
            if(component.getCursor() != Cursor.getDefaultCursor()) {  
                // If cursor is set for resizing, allow dragging.  
                dragging = true;  
            }  
        }  
       
        public void mouseReleased(MouseEvent e) {  
            dragging = false;  
        }  
       
        public void mouseDragged(MouseEvent e) {  
            if(dragging) {  
                Point p = e.getPoint();  
                ArrayList list = component.paths;  
                for(int j = 0; j < list.size(); j++) {  
                    Path2D.Double path = (Path2D.Double)list.get(j);  
                    selectedPath = path;  
                    Rectangle r = selectedPath.getBounds();  
                    int type = component.getCursor().getType();  
                    int dx = p.x - r.x;  
                    int dy = p.y - r.y;  
                    switch(type) {  
                    case Cursor.N_RESIZE_CURSOR:  
                        int height = r.height - dy;  
                        r.setRect(r.x, r.y+dy, r.width, height);  
                        break;  
                    case Cursor.S_RESIZE_CURSOR:  
                        height = dy;  
                        r.setRect(r.x, r.y, r.width, height);  
                        break;  
                    default:  
                        System.out.println("unexpected type: " + type);  
                    }  
                    component.repaint();  
                }}  
        }  
       
        public void mouseMoved(MouseEvent e) {  
            Point p = e.getPoint();  
            if(!isOverRect(p)) {  
                if(component.getCursor() != Cursor.getDefaultCursor()) {  
                    // If cursor is not over rect reset it to the default.  
                    component.setCursor(Cursor.getDefaultCursor());  
                }  
                return;  
            }  
            // Locate cursor relative to center of rect.  
            int outcode = getOutcode(p);  
            ArrayList list = component.paths;  
            Rectangle r = selectedPath.getBounds();  
            switch(outcode) {  
                case Rectangle.OUT_TOP:  
                    if(Math.abs(p.y - r.y) < PROX_DIST) {  
                        component.setCursor(Cursor.getPredefinedCursor(  
                                            Cursor.N_RESIZE_CURSOR));  
                    }  
                    break;  
                case Rectangle.OUT_BOTTOM:  
                    if(Math.abs(p.y - (r.y+r.height)) < PROX_DIST) {  
                        component.setCursor(Cursor.getPredefinedCursor(  
                                            Cursor.S_RESIZE_CURSOR));  
                    }  
                    break;  
                default:    // center  
                    component.setCursor(Cursor.getDefaultCursor());  
            }}