Hi I am working on a Turtle Program and I have put in all the fancy schmancy stuff in I just cant seem to figure out how to print the T, which is my turtle, on the screen. Here is the code for my program so far!
	Any input is appreciated thanks!
-Julian
					Code:
	/* Julian Baranowski
Date:12/7/2006
Revised:
Description: Turtle Graphics Program
*/
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
public class P7_21 extends JFrame implements ActionListener
{
	int floor[][];
	JTextArea output, input;
	JButton enter,exit;
	JScrollPane jsp;
	JTextField ent;
	Container container;
	int move[] ={8,6,4,2};
	int moved = 0;
	final int LEFT = 4, RIGHT = 6, UP = 8, DOWN = 2;
	String left,right,up,down;
	public P7_21()
	{
		left="";
		right="";
		up="";
		down="";
		container= getContentPane();
		container.setLayout(null);
		floor = new int [20][20];
		setSize(800,500);
		output = new JTextArea(20,50);
		output.setFont(new Font("Monospaced",Font.PLAIN,18));
		//output.setText("TEST");
		output.setBounds(5,5,350,300);
		output.setEditable(false);
		container.add(output);
		input = new JTextArea(5,50);
		input.setFont(new Font("Monospaced",Font.PLAIN,12));
		jsp = new JScrollPane(input);
		jsp.setBounds(430,5,360,300);
		//container.add(jsp);
		container.add(jsp);
		ent = new JTextField();
		ent.setBounds(300,350,200,20);
		ent.setEditable(true);
		ent.addActionListener(this);
		container.add(ent);
		enter = new JButton("Enter");
		enter.addActionListener(this);
		enter.setBounds(300,400,100,20);
		container.add(enter);
		exit = new JButton("Exit");
		exit.addActionListener(this);
		exit.setBounds(400,400,100,20);
		getContentPane().add(exit);
		container.add(exit);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.dispose();
		print();
		setVisible(true);
		//int floor = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}; //(Finish next time)
	}
	public void actionPerformed(ActionEvent evt)
	{
		if(evt.getActionCommand().equals("Exit"))
			{
				int choice = JOptionPane.showConfirmDialog(null,
					" You Pressed "+ evt.getActionCommand()+" is this what you want to do? ",
					" Quit Frame ",
					JOptionPane.YES_NO_OPTION);
				if( choice == 0)
				this.dispose();
			}
		if(evt.getSource()==enter || evt.getSource()==ent)
		{
			if(ent.getText().toLowerCase().compareTo("left")== 0)
			{
				left ="Key:4 (LEFT)\n";
			System.out.println("Left");
				input.append(left);
				ent.setText("");
			}//end left
			if(ent.getText().toLowerCase().compareTo("right")==0)
			{
				right ="Key:6 (RIGHT)\n";
			System.out.println("right");
				input.append(right);
				ent.setText("");
			}//end right
			if(ent.getText().toLowerCase().compareTo("up")==0)
			{
				up ="Key:8 (UP)\n";
			System.out.println("Up");
				input.append(up);
				ent.setText("");
			}//end up
			if(ent.getText().toLowerCase().compareTo("down")==0)
			{
				down ="Key:2 (DOWN)\n";
			System.out.println("Down");
				input.append(down);
				ent.setText("");
			}//end down
		}
	}
	void print()
	{
		for(int x=0;x<floor.length;x++)
		{
			for(int y=0;y<=floor[0].length;y++)
			{
				if(y==floor[0].length)
				{
					output.append("\n");
					continue;
				}//end if
				if(floor[x][y]==0)
					output.append("0");
				else
				if(floor[x][y]==1)
					output.append("T");
			}
		}
	}
		public static void main(String args[])
		{
			new P7_21();
		}
}
-Julian
Comment