Java paint line in existing JPanel with components

I’ve been searching for a few hours, including at other questions on stack such as. I need simplest way to draw a line in java in AWT panel but couldn’t find my answer. I have a panel gridbaglayout …

How to initialize and draw a Rectangle variable in a paintComponent method? [closed]

I’ve been trying to add collision to my game, it seemed like a piece of cake, I already know how to draw a rectangle. But I need that rectangle to be represented by something, a variable. But it seems …