I am new to java and I am wondering what is the best way to go about importing a class to a JFrame since I have a few minor applications I would like to make run in a window other then eclipse.
Here is some of the code I am working with (Its a modified version of some code in the dummies book):
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Random;
public class GuessAgain {
/**
* @param args
*/
public static void main(String[] args) {
// Set up input and main info
Scanner input = new Scanner(System.in);
int numGuesses = 0;
int randomNumber = new Random().nextInt(10) + 1;
// Display welcome message
out.println("~-=********************=-~");
out.println(" The Guessing Game! ");
out.println("~-=********************=-~");
// Give instruction
out.print("Please enter a number between 1 and 10: ");
int inputNumber = input.nextInt();
numGuesses++;
// Recurse till user gets the answer
while (inputNumber != randomNumber) {
out.println();
out.println("~-=********************=-~");
out.println(" Please try again ");
out.println("~-=********************=-~");
out.print("Enter another number between 1 and ten: ");
inputNumber = input.nextInt();
numGuesses++;
}
out.print("You won after: " + numGuesses + " guesses");
}
}
So how do I go about putting all of that into a window?