@Override public void mouseDragged(MouseEvent e) { Insets insets = mapper.getInsets(); int w = mapper.getWidth() - insets.right - insets.left; int minDividerPosition = MapperLayout.MIN_WIDTH; int maxDividerPosition = w - 2 * (MapperLayout.MIN_WIDTH + MapperLayout.DIVIDER_WIDTH); int leftDividerPosition = mapper.getLeftDividerPosition(); int rightDividerPosition = mapper.getRightDividerPosition(); if (e.getSource() == leftDivider) { leftDividerPosition += (e.getX() - mouseX); leftDividerPosition = Math.max(minDividerPosition, Math.min(leftDividerPosition, maxDividerPosition)); if (w - leftDividerPosition - rightDividerPosition - MapperLayout.MIN_DELTA < 0) { rightDividerPosition = w - leftDividerPosition - MapperLayout.MIN_DELTA; rightDividerPosition = Math.max(rightDividerPosition, 0); } mapper.revalidate(); mapper.repaint(); } else if (e.getSource() == rightDivider) { rightDividerPosition -= (e.getX() - mouseX); rightDividerPosition = Math.max(minDividerPosition, Math.min(rightDividerPosition, maxDividerPosition)); if (w - leftDividerPosition - rightDividerPosition - MapperLayout.MIN_DELTA < 0) { leftDividerPosition = w - rightDividerPosition - MapperLayout.MIN_DELTA; leftDividerPosition = Math.max(leftDividerPosition, 0); } mapper.revalidate(); mapper.repaint(); } if ((rightDividerPosition != mapper.getRightDividerPosition()) || (leftDividerPosition != mapper.getLeftDividerPosition())) { mapper.setDividerPositions(leftDividerPosition, rightDividerPosition); mapper.revalidate(); mapper.repaint(); } }