Changing Fonts & Font Color, JOptionPane - TechRepublic
General discussion
March 21, 2006 at 06:58 AM
hamant5

Changing Fonts & Font Color, JOptionPane

by hamant5 . Updated 14 years, 8 months ago

Can anyone help me change the Fonts & Color of my Texts..:(…?
import java.io.*;
import java.util.Random;//needed for generating random number
import java.applet.Applet;//used for display of applet windows
import java.awt.Color;//adding colour
import javax.swing.JOptionPane;
import java.awt.*;
import javax.swing.*;
import java.awt.Font;

public class Guesses extends java.applet.Applet
{
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;//from JOptionPane
String DataEntry;
String challenge=”Try to guess the number I’m thinking of!”;
String challenge2=challenge+Color.RED;
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, challenge2,”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