Not recognizing LABELEDTEXTFIELD class
import java.awt.*;
import java.util.*;
import java.applet.*;
import java.net.*;
import java.awt.event.*;
import java.applet.Applet;
public class Main extends Applet implements Runnable {
//new LabeledTextField("X Speed:", 2);
****PROBELM IS HERE***
private LabeledTextField yspeed = new LabeledTextField("Y Speed:", 2);
// Variables
// Thread
Thread thread;
// Ball
PongBall ball;
// Computer paddle
paddle computer;
paddle computer2;
//JSObject win;
//Double buffering
private Image dbImage;
private Graphics dbg;
private KeyEvent e;
private boolean upPressed = false;
private boolean downPressed = false;
public void init(){
// String xSpeed = new LabeledTextField("X Speed:", 2);
//String ySpeed = new LabeledTextField("Y Speed:", 2);
// add(xSpeed);
// add(ySpeed);
// add(new Button("Submit"));
setBackground (Color.black);
addKeyListener(new KeyInputHandler());
double randomX = Math.random()*380 + 10;
int intX = (int)randomX;
double randomY = Math.random()*240 + 10;
int intY = (int)randomY;
ball = new PongBall (intX,intY);
//if (choice == 1){
computer = new ManualPaddle (200,15, ball, 1);
//}
//if(choice == 2){
computer2 = new LinearAIPaddle (200,375, ball, -1);
//}
}
public void start(){
thread = new Thread (this);
thread.start();
}
public void stop(){
thread.stop();
}
public void run(){
//Degrade the ThreadPriority over draw to facilitate
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
while (true)
{
//New marks of the window
repaint();
ball.move();
computer.move(upPressed, downPressed);
computer2.move(upPressed, downPressed);
ball.testForCollisionComputer(computer, computer2);
try
{
//stop the threads for 10 milliseconds
Thread.sleep (10);
}
catch (InterruptedException ex)
{
break;
}
// Set the current thread to max priority
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
}
}
public void paint(Graphics g){
ball.paint(g);
computer.paint (g);
computer2.paint (g);
}
/** Update method*/
public void update (Graphics g)
{
// initialize double buffers
if (dbImage == null)
{
dbImage = createImage (this.getSize().width, this.getSize().height);
dbg = dbImage.getGraphics ();
}
dbg.setColor (getBackground ());
dbg.fillRect (0, 0, this.getSize().width, this.getSize().height);
dbg.setColor (getForeground());
paint (dbg);
g.drawImage (dbImage, 0, 0, this);
}
private class KeyInputHandler implements KeyListener {
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP) {
upPressed = true;
}
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
downPressed = true;
}
}
public void keyTyped(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP) {
upPressed = false;
}
if (e.getKeyCode() == KeyEvent.VK_DOWN) {
downPressed = false;
}
}
}
}
well do to abit of a bust in a prior attmpt at coding I'm trying to add some fields to enter data into my applet to change a few things.
but i can't get java to recognize the labeled text field object, I don't know why, i can use it in other pogram am i doing something wrong here.
Is there a better way to add data entry into the applet?
I simply want the user to be able to select teh speed for the paddles in the pong game and the speed for teh ball, and give them an option on what type of AI for the paddles, left and right.

