void (final MouseEvent e) { if (e.getID() == MouseEvent.MOUSE_PRESSED) { myLastPoint = e.getPoint(); myBounds = myOriginalParent.getLayoutManager().isGrid() ? myResizedCopy.getBounds() : myComponent.getBounds(); myOriginalBounds = new Rectangle(myBounds); } else if(e.getID()==MouseEvent.MOUSE_DRAGGED){ final int dx = e.getX() - myLastPoint.x; final int dy = e.getY() - myLastPoint.y; if (myOriginalParent.getLayoutManager().isGrid()) { final Point point = SwingUtilities.convertPoint(myEditor.getDragLayer(), e.getX(), e.getY(), myOriginalParent.getDelegee()); putGridSpanFeedback(point); } else if (myOriginalParent.isXY()) { myEditor.getActiveDecorationLayer().removeFeedback(); setCursor(getResizeCursor()); } else { return; } final GridConstraints constraints = myComponent.getConstraints(); if ((myResizeMask & Painter.WEST_MASK) != 0) { myBounds.x += dx; myBounds.width -= dx; } if ((myResizeMask & Painter.EAST_MASK) != 0) { myBounds.width += dx; } if ((myResizeMask & Painter.NORTH_MASK) != 0) { myBounds.y += dy; myBounds.height -= dy; } if ((myResizeMask & Painter.SOUTH_MASK) != 0) { myBounds.height += dy; } final Dimension minSize = myComponent.getMinimumSize(); final Rectangle newBounds = myOriginalParent.getLayoutManager().isGrid() ? myResizedCopy.getBounds() : myComponent.getBounds(); // Component's bounds cannot be less the some minimum size if (myBounds.width >= minSize.width) { newBounds.x = myBounds.x; newBounds.width = myBounds.width; } else { if((myResizeMask & Painter.WEST_MASK) != 0){ newBounds.x = newBounds.x+newBounds.width-minSize.width; newBounds.width = minSize.width; } else if ((myResizeMask & Painter.EAST_MASK) != 0) { newBounds.width = minSize.width; } } if (myBounds.height >= minSize.height) { newBounds.y = myBounds.y; newBounds.height = myBounds.height; } else { if ((myResizeMask & Painter.NORTH_MASK) != 0) { newBounds.y = newBounds.y + newBounds.height - minSize.height; newBounds.height = minSize.height; } else if ((myResizeMask & Painter.SOUTH_MASK) != 0) { newBounds.height = minSize.height; } } final Dimension size = newBounds.getSize(); Util.adjustSize(myComponent.getDelegee(), constraints, size); newBounds.width = size.width; newBounds.height = size.height; if (myOriginalParent.getLayoutManager().isGrid()) { myResizedCopy.setBounds(newBounds); } else { if (myEditor.ensureEditable()) { myComponent.setBounds(newBounds); } } myEditor.refresh(); myLastPoint=e.getPoint(); } else if (e.getID() == MouseEvent.MOUSE_RELEASED) { boolean modified = false; myComponent.getDelegee().setVisible(true); myComponent.setResizing(false); myComponent.setSelected(true); if (myResizedCopy != null) { myEditor.getDragLayer().remove(myResizedCopy.getDelegee()); } if (myOriginalParent.getLayoutManager().isGrid() && myEditor.ensureEditable()) { final Point point = SwingUtilities.convertPoint(myEditor.getDragLayer(), e.getX(), e.getY(), myOriginalParent.getDelegee()); Rectangle rcGrid = getGridSpanGridRect(myOriginalParent, myOriginalConstraints, point, myResizeMask); if (rcGrid != null && isGridSpanDropAllowed(rcGrid)) { GridConstraints oldConstraints = (GridConstraints) myOriginalConstraints.clone(); myOriginalConstraints.setColumn(rcGrid.x); myOriginalConstraints.setRow(rcGrid.y); myOriginalConstraints.setColSpan(rcGrid.width); myOriginalConstraints.setRowSpan(rcGrid.height); myComponent.fireConstraintsChanged(oldConstraints); modified = true; } } else { modified = true; } myEditor.getActiveDecorationLayer().removeFeedback(); myComponent.setDragging(false); if (modified) { if (myEditor.ensureEditable()) { myEditor.refreshAndSave(true); } } } }