• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Hangman GUI?

 
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

 
Marshal
Posts: 15873
265
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • 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.
 
Marshal
Posts: 70215
281
  • 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
Marshal
Posts: 15873
265
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • 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!
 
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic