SRL Archive - Java Help and Tutorials

Need help with GUI problem


EL_TYCHO

2010-03-18 20:13:54

Hi, I have to make a hangman script in Java, the console version was great, but now I have to get it in a gui version. Some things worked out and now I need help :(
The main problem is the game itself. Its in dutch so I hope everybody can understand it. So I need to get the game working in the gui. It may look as butt ugly as hell, I dont care, it just has to work :(
I added all my classes and wat I already have.

LolL

2010-03-18 23:51:34

I ran the program, but it's all in Dutch :duh:, so I don't know how the program should or should not function…

What's the specific problem you're having?


Edit: Okay, I found teh problemz. In Spel.java, you have:


JOptionPane.showInputDialog(null,"Welke letter kies je?");
inp = input.nextLine();

Not good. It ignores the input from the dialog that opens and waits instead for command-line input. Quick and easy fix:


inp= JOptionPane.showInputDialog(null,"Welke letter kies je?");

//inp = input.nextLine(); You can remove this line; it's pretty useless...

I played a whole game. It's looking pretty nice. :)

EL_TYCHO

2010-03-19 07:06:32

Lol, that was it? Damn, I thought that was wrong but was not sure :D

Did you play a full game in console or in GUI? Because I think the "Hangman" is not drawn in the GUI version yet when you make a mistake

Tried it myself, but it still does nothing after he asks a letter :(

weequ

2010-03-19 10:10:02

I should try learning these guy things too. But I dont have the time atm :(

LolL

2010-03-19 19:00:21

From: EL_TYCHO
Lol, that was it? Damn, I thought that was wrong but was not sure :D

The showInputDialog method returns the user input, so you definitely need to store the value.

From: EL_TYCHO

Did you play a full game in console or in GUI? Because I think the "Hangman" is not drawn in the GUI version yet when you make a mistake

The Hangman is drawn in the console. To make it draw onto the GUI, you could add an applet that draws a hangman, letters, and all that good stuff.

From: EL_TYCHO

Tried it myself, but it still does nothing after he asks a letter :(

Worked for me, but it only draws the hangman after you guess a letter wrong, otherwise it reveals the correctly-guessed letters.

I guessed "A" and it was right:

Then, I guessed a few more letters… all but one wrong:

And then I lost (blame the Dutch :f:):



@anti: fuck time, learn this shit or I'mma beat ya face in