Skip to content

Commit 7b60be3

Browse files
committed
Prevent index out of bounds error when dragging table header
1 parent 865e3d8 commit 7b60be3

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

core/src/main/java/com/github/weisj/darklaf/ui/table/header/DarkTableHeaderUI.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2019-2021 Jannis Weis
4+
* Copyright (c) 2019-2025 Jannis Weis
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
77
* associated documentation files (the "Software"), to deal in the Software without restriction,
@@ -194,6 +194,7 @@ public void paintSingleCell(final Graphics2D g, final int h, final TableColumnMo
194194
public void paintDraggedArea(final Graphics2D g, final boolean ltr, final int cMin, final int cMax,
195195
final Color borderColor, final TableColumn draggedColumn) {
196196
int draggedColumnIndex = viewIndexForColumn(draggedColumn);
197+
if (draggedColumnIndex < 0) return;
197198
boolean scrollPaneRtl = isScrollPaneRtl();
198199
Rectangle draggedCellRect = header.getHeaderRect(draggedColumnIndex);
199200
int dist = DarkTableUI.adjustDistance(header.getDraggedDistance(), draggedCellRect, header.getTable());
@@ -270,6 +271,7 @@ public void paintDraggedArea(final Graphics2D g, final boolean ltr, final int cM
270271
}
271272

272273
protected void paintCell(final Graphics g, final Rectangle cellRect, final int columnIndex) {
274+
if (columnIndex < 0) return;
273275
Component component = getHeaderCellRenderer(columnIndex);
274276
rendererPane.paintComponent(g, component, header, cellRect.x, cellRect.y, cellRect.width, cellRect.height,
275277
true);

0 commit comments

Comments
 (0)