Results 1 to 2 of 2
Thread: Placing a game in a window
- 02-12-2011, 06:10 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 47
- Rep Power
- 0
Placing a game in a window
I've made a little simple guessing game, and i wonder how i can place it inside a Jframe, instead of running it as text based in the console(Using eclipse)
I'll post the code aswell:
Edit: Don't mind my name, this is java programming :>
PHP Code:import static java.lang.System.out; import static java.lang.System.in; import java.util.Scanner; import java.util.Random; public class GuessAgain { public static void main (String[] args) { Scanner myScanner = new Scanner(System.in); int numGuesses = 0; int randomNumber = new Random().nextInt(30) +1 ; { out.println(" ***************** "); out.println("Welcome to the Guessing Game"); out.println(" ***************** "); out.println(); out.print("Enter a number from 1 to 30: "); int inputNumber = myScanner.nextInt(); numGuesses++; if (inputNumber > randomNumber){ out.println("The number is smaller then " + inputNumber);} if (inputNumber < randomNumber){ out.println("The number is bigger then " + inputNumber); } while (inputNumber != randomNumber){ out.println(); out.print("Enter a number from 1 to 30: "); inputNumber = myScanner.nextInt(); numGuesses++; if (inputNumber > randomNumber){ out.println("The number is smaller then " + inputNumber);} if (inputNumber < randomNumber){ out.println("The number is bigger then " + inputNumber); } } if (inputNumber == randomNumber);{ out.println("You managed to find the correct number!"); } out.print("You answered with the number "); out.println(randomNumber + " ,which is correct!"); out.print("You have completed the game after "); out.println(numGuesses + " guesses."); } }}
-
Thread locked as it is a duplicate of a previous post by the original poster. To the original poster, one thread on this is enough.
Similar Threads
-
Placing a game in a Jframe, gui or whatever
By AndroidAppNewbie in forum AWT / SwingReplies: 3Last Post: 02-12-2011, 07:21 PM -
Pausing game when user minimizes window
By tecno40 in forum Java AppletsReplies: 1Last Post: 12-29-2010, 05:37 PM -
placing the components
By rajeevhegde in forum AWT / SwingReplies: 1Last Post: 05-17-2010, 03:12 PM -
placing jar file
By ras_pari in forum New To JavaReplies: 1Last Post: 12-01-2009, 09:32 AM -
Placing Files In Folder
By ramesh.8189 in forum New To JavaReplies: 0Last Post: 02-06-2009, 12:36 PM


LinkBack URL
About LinkBacks

Bookmarks