jQuery in Action, 3rd edition
The moose likes Game Development and the fly likes text based java game needs gui help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "text based java game needs gui help" Watch "text based java game needs gui help" New topic

text based java game needs gui help

tobias berenson

Joined: Jul 07, 2009
Posts: 3
So i have taken my brothers code for a game he calls HEX, a simple low power type of rpg from 1k monkeys 1k typewriters.com. i am trying to create a window that will allow
his game to be played in a scrolling window, buttons for choosing actions, and making it a jar so its distributable. i am tired of using my ide (BlueJ) as the only way to do things.

when i call the main method it just starts the game, nothing different than what it used to do, and it needs to create the GUI printing the game code in the text area. if someone could point me in the write direction, its safe to say i dont really get how gui works well enough to do it on my own.

should i give you all the game code as well?
the starter of the game.

Fred Hamilton
Ranch Hand

Joined: May 13, 2009
Posts: 684
Think of it this way...

In your main GUI class, you declare a JTextArea object like you would declare any other object. By doing so, you give the JTextArea a name, that name is accessible by other code in this class, and maybe also other classes.

Now the JTextArea class has methods that allow you to specify text to be displayed. So somehwhere in your code will be a command that combines the name of the JTextArea object, with the name of the appropriate method and a variable containing the text you want to display.

That is a general explanation, to find the specifics, you will need to research the JTextArea class, and maybe Swing GUIs and Object Oriented Programming in general, in order to get the job done.

Does that help?

edited for clarity
I agree. Here's the link: http://aspose.com/file-tools
subject: text based java game needs gui help
It's not a secret anymore!