Academic Java Knowledge, Problems with Movement in Games

I took a year of Java in college, but it was mostly academic/business-oriented coding. I am trying to make my first game, and I am at the point of having 2D graphics working in Swing and a character I can move back and forth, but I am having problems with ‘jumping’. Intending to make a 2D platformer, it is integral that I figure out vertical movement. As it stands I am using a KeyListener on my canvas to move the Entity object I have created, but my control scheme seems to be very primitive. I can make the Entity move left or right or jump, but it is unable to ‘jump’ and move a direction at the same time. I am using a switch statement to control the movement as such:

public void movement(KeyEvent e) {

	switch(e.getKeyCode()) {
	
	case KeyEvent.VK_RIGHT:
		
		if(myX >= 940) {
		
			break;
			
		}
		
		myX += 10;
		break;
		
	case KeyEvent.VK_LEFT:
		
		if(myX <= 10) {
			
			break;
			
		}
		
		myX -= 10;
		break;
	
	case KeyEvent.VK_SPACE:
		
                   while(myY < 400) {
			
			myY += 20;

		}

	       while(myY > 300) {

                            myY -= 20;

                   }

		break;
		
	}
	
}

What is the standard method of creating vertical/arcing movement of an Entity in 2D space? I apologize if this information is posted elsewhere, I couldn’t find it.
Thanks in advance,

boom_box

The easiest way to get an arc is to accelerate the player downwards by a constant factor when the player is not standing on a blocking tile (e.g. ground)

To perform a jump, you would then add an initial impulse upwards and allow the downwards acceleration to erode the effect of this impulse. Eventually the impulse is countered entirely… this would be the top of the arc. Then the downwards acceleration will dominate and start to move the player back down.

i.e.


double myX,myY;
double accX,accY;

double ACCELERATION_INCREMENT=0.1;
double GRAVITY_ACCELERATION=0.1;
double MAX_ACCELERATION_X=5;
double JUMP_ACCELERATION=10;


while (gameIsAlive)
{
      myX+=accX;
      myY+=accY;

         if (!player.isOnGround)
         {
             accY-=GRAVITY_ACCELERATION;
         }

      // draw player
      
      // sleep
}

public void movement(KeyEvent e) {
      
      switch(e.getKeyCode()) {
      
      case KeyEvent.VK_RIGHT:
         accX+=ACCELERATION_INCREMENT;
         if(accX >= MAX_ACCELERATION_X) {
         accX=MAX_ACCELERATION_X;
            
         }
         
      case KeyEvent.VK_LEFT:
           accX-=ACCELERATION_INCREMENT;
         if(accX <= -MAX_ACCELERATION_X) {
         accX=-MAX_ACCELERATION_X;
            
         }
      
      case KeyEvent.VK_SPACE:
         if (player.isOnGround)
         {
             accY+=JUMP_ACCELERATION;
         }
          
         
      }
      
   }


Thank you.