Foros del Web » Programación para mayores de 30 ;) » Java »

ubicacion del texto

Estas en el tema de ubicacion del texto en el foro de Java en Foros del Web. Hola, estoy haciendo un programa utilizando un applet para el juego rock, paper, scissors. El programa corre, pero me falta un paso final que no ...
  #1 (permalink)  
Antiguo 13/04/2008, 14:30
 
Fecha de Ingreso: marzo-2008
Mensajes: 13
Antigüedad: 16 años, 1 mes
Puntos: 0
ubicacion del texto

Hola,

estoy haciendo un programa utilizando un applet para el juego rock, paper, scissors. El programa corre, pero me falta un paso final que no tengo idea como hacerlo.

cuando corro el programa, se ven 4 botones (Rock, paper, scissors, start) y atras de estos se ve un texto "Rock, Paper, Scissors". Este texto dbe ir como un titulo en letras grandes y centrado, ademas de permanecer siempre en ese sitio. Les agradezco cualquier ayuda

Gracias

Código:
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;


public class JRockPaperScissors extends Applet implements ActionListener
{
int computer;
int user;
int z = 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;
z = user - computer;
}

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

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

//When Start is pressed
if (cmd.equals("Start"))
{
if (start == true)
{
start = false;
setBackground(Color.gray);
repaint();
z = 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);
}
}
}
}
  #2 (permalink)  
Antiguo 16/04/2008, 22:38
 
Fecha de Ingreso: marzo-2008
Mensajes: 13
Antigüedad: 16 años, 1 mes
Puntos: 0
Re: ubicacion del texto

Hola, alguien que me pueda ayudar...... gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:51.