Ayuda con texto en applet

nogal
17 de Abril del 2008
Hola,

Tengo un applet casi listo y necesito ayuda con un codigo que no he encontrado la forma de hacerlo. el programa es el juego de piedra, papel, tiijera.

Cuando se despliega el applet, se veran 4 botones y detras de estos un letrero "Rock, Paper, Scissors". Este letrero debe permanecer en ese sitio, centrado mientras el jugador este jugando. Ademas debe tener una letra mas grande, como titulo y luego si debajo los botones y el resto.......

Aqui esta el codigo... gracias

[code]

import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;


public class rockpaperscissorsa extends Applet implements ActionListener
{
int computer;
int user;
int t = 5;
boolean start = true;
int cscore = 0;
int dscore = 0;
int uscore = 0;

private Font f = new Font("Arial", Font.PLAIN, 12);

public void init() {


// Rock button
Button rockButton = new Button("Rock");
add(rockButton);
rockButton.addActionListener(this);

// Paper button
Button paperButton = new Button("Paper");
add(paperButton);
paperButton.addActionListener(this);

// Scissors button
Button scissorsButton = new Button("Scissors");
add(scissorsButton);
scissorsButton.addActionListener(this);

// Start button
Button startButton = new Button("Start");
add(startButton);
startButton.addActionListener(this);

// initial background color
setBackground(Color.gray);

}

public void actionPerformed(ActionEvent e)
{

// To know which button was pressed
String cmd = e.getActionCommand();

// Rock is played
if (cmd.equals("Rock"))
{
user = 1;
setBackground(Color.gray);
repaint();
computer = (int) (Math.random()*3)+1;
t = user - computer;
}

// Paper is played
if (cmd.equals("Paper"))
{
user = 2;
setBackground(Color.gray);
repaint();
computer = (int) (Math.random()*3)+1;
t = user - computer;
}

// Scissors is played
if (cmd.equals("Scissors"))
{
user = 3;
setBackground(Color.gray);
repaint();
computer = (int) (Math.random()*3)+1;
t = user - computer;
}

//When Start is pressed
if (cmd.equals("Start"))
{
if (start == true)
{
start = false;
setBackground(Color.gray);
repaint();
t = 5;
cscore = 0;
uscore = 0;
dscore = 0;
}
else {
start = true;
repaint();
}
}
}

public void paint( Graphics g )
{


if (start == true)
{

//introduction
g.drawString("Rock, Paper, Scissors.", 130, 10);
g.drawString("Click the buttons above to play.", 5, 75);
g.drawString("Click start to begin.", 5, 90);
}

else if (start == false)
{

// Results
switch(t)
{
case 0 : g.drawString("It's a draw.", 5, 120);
dscore++;
break;

case 1 : case -2 : g.drawString("You won.", 5, 120);
uscore++;
break;

case -1 : case 2 : g.drawString("I won.", 5, 120);
cscore++;
break;
}

// Show results
g.drawString("Number of user wins," + uscore, 5, 170);
g.drawString("Number of computer wins" + cscore, 5, 185);
g.drawString("Number of draws," + dscore, 5, 200);

// Displaying computer's choices
if (computer == 1)
{
g.drawString("PC picked Rock.", 5, 70);
}
if (computer == 2)
{
g.drawString("PC picked Paper.", 5, 70);
}
if (computer == 3)
{
g.drawString("PC picked Scissors.", 5, 70);
}

// Displaying user's choices
if (user == 1)
{
g.drawString("You picked Rock.", 5, 85);
}
if (user == 2)
{
g.drawString("You picked Paper.", 5, 85);
}
if (user == 3)
{
g.drawString("You picked Scissors.", 5, 85);
}
}
}
}

[/code]

nogal
17 de Abril del 2008
Hola,

Alguien que pueda ayudarme??????