|
|
|
@ -359,9 +359,21 @@ public class UIEastResizableContainer extends JPanel {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This inner class handles mouse events for resizing the container |
|
|
|
|
* by dragging the left edge of the right pane. |
|
|
|
|
*/ |
|
|
|
|
public class ResizeListener extends MouseAdapter implements MouseMotionListener { |
|
|
|
|
|
|
|
|
|
// Stores the point where the mouse was initially pressed
|
|
|
|
|
private Point mouseDownCompCoords; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This method is called when the mouse is moved within the component. |
|
|
|
|
* It changes the cursor to indicate that resizing is possible. |
|
|
|
|
* |
|
|
|
|
* @param e The MouseEvent. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void mouseMoved(MouseEvent e) { |
|
|
|
|
if (e.getX() <= RESIZE_RANGE) { |
|
|
|
@ -371,6 +383,12 @@ public class UIEastResizableContainer extends JPanel {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This method is called when the mouse is pressed near the left edge. |
|
|
|
|
* If within the resize area, the mouse position is stored for dragging. |
|
|
|
|
* |
|
|
|
|
* @param e The MouseEvent. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
|
if (e.getX() <= RESIZE_RANGE) { |
|
|
|
@ -378,11 +396,18 @@ public class UIEastResizableContainer extends JPanel {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This method is called when the mouse is dragged after being pressed |
|
|
|
|
* near the left edge. It adjusts the container width based on drag distance. |
|
|
|
|
* |
|
|
|
|
* @param e The MouseEvent. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
|
if (mouseDownCompCoords != null && getCursor().equals(westResizeCursor)) { |
|
|
|
|
Point currCoords = e.getLocationOnScreen(); |
|
|
|
|
int newWidth = containerWidth - (currCoords.x - mouseDownCompCoords.x); |
|
|
|
|
// Update container width within allowed range
|
|
|
|
|
if (newWidth >= MIN_CONTAINER_WIDTH && newWidth <= MAX_CONTAINER_WIDTH) { |
|
|
|
|
containerWidth = newWidth; |
|
|
|
|
mouseDownCompCoords = currCoords; |
|
|
|
@ -391,6 +416,12 @@ public class UIEastResizableContainer extends JPanel {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This method is called when the mouse button is released. |
|
|
|
|
* It clears the stored starting point for dragging. |
|
|
|
|
* |
|
|
|
|
* @param e The MouseEvent. |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void mouseReleased(MouseEvent e) { |
|
|
|
|
mouseDownCompCoords = null; |
|
|
|
|