Adding Fonts and Colour in a .java Game - TechRepublic
General discussion
March 17, 2006 at 06:44 AM
hamant5

Adding Fonts and Colour in a .java Game

by hamant5 . Updated 20 years, 3 months ago

Can’t seem to incorporate new Fonts() and Colour into my Game…Any Suggestions?:import java.io.*;
import java.util.Random;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JOptionPane;
import java.io.PrintStream;
import java.awt.*;
import javax.swing.*;

public class Guesses extends JFrame
{
public static void main(String[] args) throws IOException
{

Random generator = new Random();//generator represents random number
int number;
number = generator.nextInt(100) + 1;

int guess=number;
String myNumber;
String DataEntry;
String challenge=”Try to guess the number I’m thinking of!”;
String high=”too high – guess again:”;
String low=”too low – guess again:”;
String correct1=”Finally you got it out! You only took “;
String correct2=” tries to get the correct number “;

JOptionPane.showMessageDialog( null, challenge,”Today’s Challenge: “,
JOptionPane.INFORMATION_MESSAGE );

int myInt;
BufferedReader in =new BufferedReader(new InputStreamReader(System.in));
boolean found=false;

for(int i=1;(!found);i++)
{

DataEntry = JOptionPane.showInputDialog( “Type your number here:” );
myInt=Integer.parseInt(DataEntry);

if (guessmyInt)
JOptionPane.showMessageDialog(null, low,”Today’s Challenge: “,
JOptionPane.INFORMATION_MESSAGE);

else {
JOptionPane.showMessageDialog(null, correct1+i+correct2+number,
“Today’s Challenge: “,
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
}
}

This discussion is locked

All Comments