• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hangman GUI?  RSS feed

 
Skyler Fortgang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've written a basic game of hangman (with a couple bugs to work out), and I was wondering if it is possible to link that program to a GUI in such a way that I could have a text box for the user to make their guesses, press a button to call my makeGuess() method, display the Array I have to represent letters guessed correctly etc. Attached is the Hangman class and it's test client. Any help would be appreciated, I don't know much about GUIs! Thanks!

Hangman.java



Tester

 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Skyler Fortgang wrote:I don't know much about GUIs! Thanks!

There's a tutorial for that: https://docs.oracle.com/javase/tutorial/2d/

Instead of this:

it's better to do this:

This automatically initializes the array WORDS when you run your program and you only need to refer to in the rest of your code.
 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu Lacar wrote: . . . This automatically initializes the array WORDS when you run your program and you only need to refer to in the rest of your code.
Also, if you make any changes to that array initialiser, the length of the array will automatically be changed to accommodate those changes.
 
Skyler Fortgang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the bug fix guys but I'm really concerned about the GUI here any thoughts on how to get started?
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you missed it but I gave you a link to a tutorial you might want to check out: https://docs.oracle.com/javase/tutorial/2d/

If you create separate images for the hangman parts, you can draw those images on a canvas. Here's the section of the same tutorial for that: https://docs.oracle.com/javase/tutorial/2d/images/index.html
 
Skyler Fortgang
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops sorry! Viewed it on my phone. Thanks a bunch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!