please help with my hangman game I have some code but need a lot of help with rest.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: please help with my hangman game I have some code but need a lot of help with rest.

  1. #1
    Join Date
    Oct 2005
    Posts
    3

    Please help with my hangman game I have encluded it in a zip file but need help badly

    i have made some progress with my hangman game but i cant keep the letter that the player chooses to remain in the label because it gets overwriten by the new letter chosen. Can anyone help me please or has anyone got a very simple hangman game that i could look at to get an idea of how it works. I have encluded some of the code that i am using for my one below also a zip file of what i have written regarding the actual game. Of course if anyone knows of an easyer way of doing things i would be very gratefull if they could show me.

    private JLabel title;

    //panel 1
    panel1.add (title);

    public void keyTyped(KeyEvent event)
    {
    char key = event.getKeyChar();
    title .setText(""+key);
    }

    Please help as i have been stuck on this hangman game for two weeks and am getting no where apart form getting a headache and frustrated
    Attached Files Attached Files
    Last edited by kma9; 10-29-2005 at 05:20 AM. Reason: encluded hangman zip file

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    This works fine in IE

    ...but fails miserably in Opera, hmm..?

    Code:
    public void keyTyped(KeyEvent event) {
        char key = event.getKeyChar();
        String s=title.getText().trim();
        if (!s.equalsIgnoreCase("Hangman Game")) {
          title.setText(s + key);
        } else {
          title.setText(""+key);
        }
      }
    eschew obfuscation

  3. #3
    Join Date
    Oct 2005
    Posts
    3
    Thanks sjalle that work great and was just what I needed. Now I just need to try to find a way of doing the rest. Thanks again you are a life saver.

Similar Threads

  1. Replies: 3
    Last Post: 03-09-2005, 12:24 AM
  2. Replies: 60
    Last Post: 09-13-2002, 06:41 PM
  3. Replies: 0
    Last Post: 04-11-2002, 07:48 PM
  4. Is There Something Difficult About VB.NET?
    By Zane Thomas in forum .NET
    Replies: 332
    Last Post: 07-09-2001, 06:48 PM
  5. Replies: 0
    Last Post: 04-03-2001, 05:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center