The screen for java applets usually are refreshed many times per second. Usually, I use 20 frames per second.
You just need to draw the rectangle and string (near the selected particle) to follow the chosen ball at each frame in the simulation. So the tag/label will move with the particle (it is not static).
For example: if the coordinate for the chosen particle is x,y with size dx,dy.
Then you can draw rectangle with
g.drawRect(x+dx/2, y-2*dy, w, h);
where w, h should be larger than  width and hight for the label to be displayed.