Most Swing ready-made components support this embedded system (JTree, JList, etc.). For these components, you can set the reset mode, and ui will handle the corresponding visual effects.
myJList.setDropMode(DropMode.ON_OR_INSERT);
For a custom component, you need to process the drawing yourself by overriding paintComponent to draw custom effects, and then adding the PropertyChangeListener property to the dropLocation property, which causes the necessary redraws when necessary. This will often be caused by drag and drop, so you can simply call repaints when a change in the forwarding location actually leads to a change in behavior.
Drop Personnel Rendering Tutorial
source share