[JAVA]Bullet shooting logic

How do I make a bullet move upward from the player position from when the key spacebar is pressed. I set up a bullet class that holds an image. in my class extending JPanel or canvas that actually draws it, how do I make a for loop or whatever else you use for drawing it.

Basicly help me understand how bullet logic works and how you use it