HINTS

In order to understand the output, you need to take into account that if your turtle is going up, its left is your left. But if it's going down, its right is your left. Also, you can draw a line, only if your pen is "down".
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;

public class TurtleGraphics extends Applet 
    implements ActionListener, AdjustmentListener {
    private Button upButton;
    private Button downButton;
    private Button leftButton;
    private Button rightButton;
    private Button forwardButton;
    
    private Scrollbar bar;
    
    private String buttonPressed = ""; // the label of the button pressed
    private int stepSize = 25; // value indicated by the slider
    

    /*
       You may want to add the following variables
   */
    private int direction = 3; //This is for the current direction
                               //You can say 1 is north, 3 is south,
                               //2 is West, and 4 is East. HOwever, 
                               //you have a lot of freedom here. 
    private int currentX = 0;//Initially your on the left top.
    private int currentY = 0;
    private boolean penUp = false; //Initially your pen is up.
    private boolean forward = false;//This is your tool to draw a line of 
                                    //size stepSize. It is  like 
                                    //a pen.

    public void init() {
	upButton = new Button("Up");
	downButton = new Button("Down");
	leftButton = new Button("Left");
	rightButton = new Button("Right");
	forwardButton = new Button("Forward");
	add(upButton);
	add(downButton);
	add(leftButton);
	add(rightButton);
	add(forwardButton);
	upButton.addActionListener(this);
	downButton.addActionListener(this);
	leftButton.addActionListener(this);
	rightButton.addActionListener(this);
	forwardButton.addActionListener(this);
	
	bar = new Scrollbar(Scrollbar.HORIZONTAL, stepSize, 1, 0, 50);
	add(new Label("step size"));
	add(bar);
	bar.addAdjustmentListener(this);
    }
    public void adjustmentValueChanged(AdjustmentEvent e) {
	stepSize = bar.getValue();
	repaint();
    }

    /*  
       Add this method to your code. It will cause your
       drawing to stay. If you don't add this, every time 
       an action happens, your las line will go away.
    */ 
    public void update(Graphics g){
	paint(g);
	requestFocus();
    }

    public void actionPerformed(ActionEvent event) {
	buttonPressed = ((Button)event.getSource()).getLabel();
	 
	if(buttonPressed.equals("Up")){
	    //What will happen to you boolean variable penUp 
            //if you press the button "Up"?	
	   
	}
	
	else if(buttonPressed.equals("Down")){
	   //What will happen to you boolean variable penUp 
           //if you press the button "Down"?	
	  
	}
	
	else if(buttonPressed.equals("Left")){
	   // Use a convenient method to turn left here.
	    
	}

	else if(buttonPressed.equals("Right")){
	   // Do something similar 
	    
	}

	else if(buttonPressed.equals("Forward")){
	   //Tell the machine that you have pressed the button
	   //forward. Set up a convenient boolean variable. 
           
	}
	repaint();
    }
    
    public void paint(Graphics g) {
	if(forward){
	    draw(g);
	    forward = false;
	}
    }

    void turnLeft(){    
	//Define a method to turn left.
        //If you use 1 for North, and if you use 2 for West, 
        //how do you go left.
        // If you 4 for East, how do you go NOrth.
       //Extra Hint: Remember the mod operation (%).
    }

    void turnRight(){
	//Define a method to turn right;
    }
    
    void draw(Graphics g){
	if(direction == ?? ){//If direction == North
	    if (!penUp) g.drawLine(//Which line do you have to draw here);
	    currentY = currentY-stepSize; //Update your new position.
	}
	
	else if(direction == ??){//South
	    if (!penUp)  g.drawLine(//Which line?);
	    currentY = currentY+stepSize;
	}
	
	else if(direction ==  ??){//East
	    if (!penUp)  g.drawLine(//Which line?);
	    currentX = currentX+stepSize;
	}
	
	else if(direction == ??){//West
	    if (!penUp)  g.drawLine(//Which line?);
	    currentX = currentX-stepSize;
	}	

	
    }
}