Reputation: 33
The goal in mind is to take the text-based game and wrap it in a GUI (not really anything advanced, just a window). I know how JFrames works, so would this be as simple as creating the JFrame GUI and writing out the game using:
g.drawString(str, x, y);
The problems I'd see myself running into would be any user input. Receiving yes/no answers, setting/getting variables, or putting code -into- the JFrame.
Actually, can methods be called into "g.drawString();", or is there some sort of function to call a method into a JFrame? If so, this would answer my question.
Upvotes: 0
Views: 156
Reputation: 4534
Yes you can call function inside drawString()
The first parameter of drawString()
is a String
object, so a function returning String
can be called inside drawString()
.
Example
public String foo(){
String str ="";
//modify string
return str;
}
calling foo()
inside drawString()
g.drawString(foo(),x,y);
Upvotes: 1