473,385 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need help to make A Hangman

Ok hes the thing u no public class thats how i gotta make it in JCreator and i dont even no where to start if anyone could give me some pointer or make the code and i use bits and piece That would really help that would be Great Thanks!!
ps its in JCreator and i a real new at this so if you do make it with code try and make it easy like only 1-3 hangman words so a shorter game lol and easy code if that makes sence lol like the Words Keyboard ,Mouse ,and i dono speaker or something
Jun 1 '07 #1
57 13297
blazedaces
284 100+
Ok hes the thing u no public class thats how i gotta make it in JCreator and i dont even no where to start if anyone could give me some pointer or make the code and i use bits and piece That would really help that would be Great Thanks!!
ps its in JCreator and i a real new at this so if you do make it with code try and make it easy like only 1-3 hangman words so a shorter game lol and easy code if that makes sence lol like the Words Keyboard ,Mouse ,and i dono speaker or something
Please find and read the posting guidelines. We're not going to do your homework for you. If you make a valid attempt at this problem and then have problems with specific parts in the code or are having errors you don't understand then we will be glad to help you.

As for pointers, I don't even know where to start, there's a lot more that goes into the hangman game then just words and letters.

Good luck,
-blazed
Jun 1 '07 #2
Please find and read the posting guidelines. We're not going to do your homework for you. If you make a valid attempt at this problem and then have problems with specific parts in the code or are having errors you don't understand then we will be glad to help you.

As for pointers, I don't even know where to start, there's a lot more that goes into the hangman game then just words and letters.

Good luck,
-blazed
Srry Man i Didnt no Im new at this hole java thing thanks
Jun 1 '07 #3
blazedaces
284 100+
Srry Man i Didnt no Im new at this hole java thing thanks
P.S. I also don't think it's quite understandable what you need. Do you want a hangman game that just prints on the screen something like this:
Expand|Select|Wrap|Line Numbers
  1. _ _ _ _                               // Computer Output
  2. Please guess a letter:      // Computer Output
  3. r                                     // User Input
  4. Sorry, that's not correct,   // Computer Input
  5. you have only 9 chances left.   // Computer Input
  6. Please guess a letter:      // Computer Output
  7.  
OR do you want a pop up visual screen with an actual hangman that changes every time along with big letters and an updating painted screen every time a letter is correct or something (sounds more challenging then the actual game concept).

I don't know.

So maybe decide on exactly what you want first before you try and make it/ask someone for help on it?

Good luck,
-blazed
Jun 1 '07 #4
P.S. I also don't think it's quite understandable what you need. Do you want a hangman game that just prints on the screen something like this:
Expand|Select|Wrap|Line Numbers
  1. _ _ _ _                               // Computer Output
  2. Please guess a letter:      // Computer Output
  3. r                                     // User Input
  4. Sorry, that's not correct,   // Computer Input
  5. you have only 9 chances left.   // Computer Input
  6. Please guess a letter:      // Computer Output
  7.  
OR do you want a pop up visual screen with an actual hangman that changes every time along with big letters and an updating painted screen every time a letter is correct or something (sounds more challenging then the actual game concept).

I don't know.

So maybe decide on exactly what you want first before you try and make it/ask someone for help on it?

Good luck,
-blazed

yeh But i need to start like with the Imports then public class hangman then Public Static void main(String args[])....yea so like u will have say 8 guess so user guess A and the word was Apple it would go "A----" then if they guess E it would go "A---E" but if they guessed H It would say srry That is Incorrect Please guess agine does that make sence?
Jun 1 '07 #5
blazedaces
284 100+
yeh But i need to start like with the Imports then public class hangman then Public Static void main(String args[])....yea so like u will have say 8 guess so user guess A and the word was Apple it would go "A----" then if they guess E it would go "A---E" but if they guessed H It would say srry That is Incorrect Please guess agine does that make sence?
Alright, well you basically know what you want to do... so how about instead of tackling the syntax (the import stuff and static void bla bla) specifics, try just writing the logic/psuedocode.

Like start by thinking, ok, how do I choose what word pops up? Is it always the same first one? Is it random? Let's say it's random, ok first few steps in psuedocode would say:

Store words word1, word2, word3 in a set of some sort.
Pick a random number 1-3
Print these: "-" for the length of whatever numbered word we chose
Print "Please guess a letter"
... Do you get it?

Try to write all the psuedocode that should be written down, if you have difficulty with a specific part, write down again, what do you want it to do as much as possible. Then, instead of telling you what to do, I'll guide you to examples, or tell you to search for specific things or give you links to java classes and what to import and whatnot.

I know that coding is something hard to do for the first time, but the challenge is mostly the logic, the HOW can this be done logically? Then syntax specifics you either learn over time or you look it up, it's all in books and on the internet. With so many programming languages each better/needed in different situations, you have to adjust yourself accordingly.

Good luck,
blazed
Jun 1 '07 #6
lol This is so confusing i think im gonna make it one have like 2 words but not ramdom just one after the other but im so lost lol what is that code called like applet or i dont even no lol that might not even make sence like what kind of code is public class
Jun 1 '07 #7
Yo im thinking about making a Maze instead lol just use ur mouse to get through it or something u think that would be easyer cause hangman is to complex for me lol
Jun 1 '07 #8
DeMan
1,806 1GB
I don't think a maze will be any easier (particularly a mouse oriented one)
Jun 1 '07 #9
I don't think a maze will be any easier (particularly a mouse oriented one)

lol u got any ideas how to do it?like should i get a image of a maze off the internet?
Jun 1 '07 #10
lol u got any ideas how to do it?like should i get a image of a maze off the internet?
o what about a arrow key? i dono i got this project to make a game and im trying to think of a simple one that i can make
Jun 1 '07 #11
DeMan
1,806 1GB
I think the Hangman example is simpler and we should start there....

One approach would be to first make a 'boring' version that always gives the same word.
Once you have refined this to work nicely we can worry about adding more words.

I think if we are going to help you, it is important for us to understand how much Java do you know. Have you written anything in java before (say a simple "Hello World" even?)

If you can isolate where your dificulty lies in the problem, we can work on that difficulty.
Reiterating what blazedaces said:
The posting guidelines expressly forbid anyone from posting complete code, so we will have to work through the problem to help YOU to solve it, rather than give you a completed solution.

If the entire problem is confusing for you, the first step (again as pointed out by blazedaces) is to simplify the problem into smaller steps. Even if you don't know exactly how you will implement the smaller steps, it at least gives you an idea of simpler tasks you need to achieve
Jun 1 '07 #12
I think the Hangman example is simpler and we should start there....

One approach would be to first make a 'boring' version that always gives the same word.
Once you have refined this to work nicely we can worry about adding more words.

I think if we are going to help you, it is important for us to understand how much Java do you know. Have you written anything in java before (say a simple "Hello World" even?)

If you can isolate where your dificulty lies in the problem, we can work on that difficulty.
Reiterating what blazedaces said:
The posting guidelines expressly forbid anyone from posting complete code, so we will have to work through the problem to help YOU to solve it, rather than give you a completed solution.

If the entire problem is confusing for you, the first step (again as pointed out by blazedaces) is to simplify the problem into smaller steps. Even if you don't know exactly how you will implement the smaller steps, it at least gives you an idea of simpler tasks you need to achieve
\


Alrite sounds good yea i have done a helloworld and other "easy "programs like some if statements....but for this hangman thing i dont no wheer to start like should i use String or i dont really no lol
like Public class HangMan
{
public startic void main(String args[])
{
String.... lol i dont no
}


}
}
Jun 2 '07 #13
nomad
664 Expert 512MB
\


Alrite sounds good yea i have done a helloworld and other "easy "programs like some if statements....but for this hangman thing i dont no wheer to start like should i use String or i dont really no lol
like Public class HangMan
{
public startic void main(String args[])
{
String.... lol i dont no
}


}
}
I'm a beginner myself and I just might do this one as well.
Here are some things to think about
1. set up your objects. 26 right
2. next you need to decide how you are going to catch the info from the user.
input or click a button for the letters (I like that one) requires listeners
3. next do you want to have a ramdom words chosen static, or can someone type one in.
4. how are you going to test it. use a if statement, switch with break...for loop
5. last how are you going to draw the hangman ie will need to repaint each event.
6. do you want to use an array
I'm sure there are more thing than this but its a good start.

nomad
Jun 2 '07 #14
I'm a beginner myself and I just might do this one as well.
Here are some things to think about
1. set up your objects. 26 right
2. next you need to decide how you are going to catch the info from the user.
input or click a button for the letters (I like that one) requires listeners
3. next do you want to have a ramdom words chosen static, or can someone type one in.
4. how are you going to test it. use a if statement, switch with break...for loop
5. last how are you going to draw the hangman ie will need to repaint each event.
6. do you want to use an array
I'm sure there are more thing than this but its a good start.

nomad


Ok Will for The hang man i idea i was just going to go something like _ _ _ _ _ ok and if u miss a letter a message will pop up and say sory that is incorrect u have 6 guess left then that avoids the hole picture of the hangman and keeps it a little less complex
Jun 2 '07 #15
nomad
664 Expert 512MB
Ok Will for The hang man i idea i was just going to go something like _ _ _ _ _ ok and if u miss a letter a message will pop up and say sory that is incorrect u have 6 guess left then that avoids the hole picture of the hangman and keeps it a little less complex
That a great ideal.
I think you can use ASCII Characters for the alphabet and for - and ' .
ie
Expand|Select|Wrap|Line Numbers
  1. for (var i = 65; i <= 90; i++)
//65 is the letter A an so on down the line.
I don't yet know How you can call the ASCII Code.
Many be someone can help you with that.

For ramdom words make a array if you are going to do it that way.

nomad
Jun 2 '07 #16
JosAH
11,448 Expert 8TB
I think you can use ASCII Characters for the alphabet and for - and ' .
ie
Expand|Select|Wrap|Line Numbers
  1. for (var i = 65; i <= 90; i++)
//65 is the letter A an so on down the line.
I don't yet know How you can call the ASCII Code.
Here's a tip for both of you: don't ever do that. The only numeric literal constants
in a piece of code should be plus or minus one or zero. All other constant values
are considered 'magic' and very bad practice. Leave that loop like this:

Expand|Select|Wrap|Line Numbers
  1. for (char i= 'A' i <= 'Z'; i++) ...
  2.  
And while I'm at it: String operations don't require much looping; it's all so very
'mechanical'. Use the String class's methods and pay special attention to the
regular expression methods, e.g. given the secret word "apple" and a guess
(a single character String), the following does this:

Expand|Select|Wrap|Line Numbers
  1. String secret= "apple"; // the secret word
  2. String correctChars= "p"; // previously correctly guessed chars
  3. String guess= "e"; // the new guess
  4. String newSecret= secret.replaceAll("[^"+correctChars+guess+"]", "-");
  5.  
The value of newSecret will be equal to "a--l-"; if you want to make sure that
the remaining new 'secret' doesn't contain any hidden letters do this:


Expand|Select|Wrap|Line Numbers
  1. boolean win(String secret, String correctChars) {
  2.    String temp= secrect.replaceAll("[^"+correctChars+"]", "-");
  3.    return temp.indexOf('-') < 0;
  4. }
  5.  
now go and read the API docs and figure it out for yourself ;-)

kind regards,

Jos
Jun 2 '07 #17
Here's a tip for both of you: don't ever do that. The only numeric literal constants
in a piece of code should be plus or minus one or zero. All other constant values
are considered 'magic' and very bad practice. Leave that loop like this:

Expand|Select|Wrap|Line Numbers
  1. for (char i= 'A' i <= 'Z'; i++) ...
  2.  
And while I'm at it: String operations don't require much looping; it's all so very
'mechanical'. Use the String class's methods and pay special attention to the
regular expression methods, e.g. given the secret word "apple" and a guess
(a single character String), the following does this:

Expand|Select|Wrap|Line Numbers
  1. String secret= "apple"; // the secret word
  2. String correctChars= "p"; // previously correctly guessed chars
  3. String guess= "e"; // the new guess
  4. String newSecret= secret.replaceAll("[^"+correctChars+guess+"]", "-");
  5.  
The value of newSecret will be equal to "a--l-"; if you want to make sure that
the remaining new 'secret' doesn't contain any hidden letters do this:


Expand|Select|Wrap|Line Numbers
  1. boolean win(String secret, String correctChars) {
  2.    String temp= secrect.replaceAll("[^"+correctChars+"]", "-");
  3.    return temp.indexOf('-') < 0;
  4. }
  5.  
now go and read the API docs and figure it out for yourself ;-)

kind regards,

Jos


Lol Is this going to be hard i think lol i dont no if my java skills r up for it but im gonna have to try cayuse i need to make a game in 2 weeks lol so ill give it a shot
Jun 2 '07 #18
DeMan
1,806 1GB
With two of you (you and nomad) attempting to work through the problem for the first time, it will be easier, and if you both run into strife, some of the experts here will help you out. Usually the biggest hurdle is starting....
Jun 3 '07 #19
That a great ideal.
I think you can use ASCII Characters for the alphabet and for - and ' .
ie
Expand|Select|Wrap|Line Numbers
  1. for (var i = 65; i <= 90; i++)
//65 is the letter A an so on down the line.
I don't yet know How you can call the ASCII Code.
Many be someone can help you with that.

For ramdom words make a array if you are going to do it that way.

nomad

Ok so Nomad how do u want to do this im thinking a simple as posable so like we wont have a hangman picture just _ _ _ _ and i think maybe just type in the letter rather then click it what u think?
Jun 3 '07 #20
Man i think we sould try and get this game running with just one word then add on from there like just keep it very simple and basic what u think?
Jun 3 '07 #21
DeMan
1,806 1GB
Good idea...,
We can cut this into a series of programs that build on the previous.

1) write a program that displays a string on the screen (done - "hello world")
2) write a program that takes a character as input an displays in on the screen.
3) write a program that stores characters entered in a list an can tell a user if a character has previously been selected
4) Using JosAH's suggestion before, expand (3) to show all the characters in (1) that have been correctly guessed.

That should be a good start, post again when you need more help.
Jun 3 '07 #22
nomad
664 Expert 512MB
Man i think we sould try and get this game running with just one word then add on from there like just keep it very simple and basic what u think?
That will be find. Since this is your class project I will try to help you as best as I can. You need to do the work, but I will give you clues and help you when you get stuck along with the real pros here at thesripts.

nomad
Jun 3 '07 #23
DeMan
1,806 1GB
That will be find. Since this is your class project I will try to help you as best as I can. You need to do the work, but I will give you clues and help you when you get stuck along with the real pros here at thesripts.

nomad
Sorry I thought you were MIA.....I'll leave you to it....
Jun 3 '07 #24
nomad
664 Expert 512MB
Sorry I thought you were MIA.....I'll leave you to it....
I will need help as well. I'm just took one class and I want to modivate others like Jos did for me. I enjoy helping others. I have Ideal on how to do it but will it work that's the big question.
Jun 4 '07 #25
DeMan
1,806 1GB
That's good!!!
If you help "Need help54321" with what you know, and we'll keep an eye on this thread, and help out whenever you get stuck or run into any difficulty.
Jun 4 '07 #26
Ok will i didnt really like the hangman thing so i decided to switch to a mini putt heres what i got could anyone tell me how to get the course and the ball to pop up togher cause i can only get one or the other and could someone tell me how to get the ball to move?please


import javax.swing.*;
import java.awt.*;
public class FristPanel
{
public static void main(String args [])
{
JFrame jf1 = new JFrame("This Is the First Frame");
JLabel lbl1 = new JLabel();
JLabel lbl2 = new JLabel();
jf1.setSize(500,500);
Container c = jf1.getContentPane();

ImageIcon icon = new ImageIcon("Golf.jpg");
lbl1.setIcon(icon);

c.add(lbl1);

ImageIcon icon2 = new ImageIcon("golfball.jpg");
lbl2.setIcon(icon2);

c.add(lbl2);

jf1.setVisible(true);

}
}
Jun 4 '07 #27
JosAH
11,448 Expert 8TB
Ok will i didnt really like the hangman thing so i decided to switch to a mini putt heres what i got
So you're simply bailing out without solving anything and leaving everything and
everybody behind? Ok, success with your endeavours then.

Jos
Jun 4 '07 #28
So you're simply bailing out without solving anything and leaving everything and
everybody behind? Ok, success with your endeavours then.

Jos
No my teacher didnt like the idea of hangman i dono y
Jun 4 '07 #29
blazedaces
284 100+
No my teacher didnt like the idea of hangman i dono y
Your abilities reflect poorly on your teacher. Your misunderstanding as to why he didn't "like the idea of hangman" only worsens his image.

Unfortunately, I don't know the nature of this assignment, nor what goals this teacher has in teaching you java. It's only frustrating because you (and many people here) contributed much effort into procuring this project (and we barely scratched its surface. It really seemed like you could have learned a lot from the process. But now you will move on to something relatively unimportant just because the teacher might like the idea of visualizing golf balls.

In my educated opinion mini-put stresses syntax (java visual/GUI specifics, the not-so-important step in programming) and ignores problem-solving/logic puzzles (the HOW do you do this or that, the psuedocode that is so hard for people to think up when they first start programming).

This is the very problem with most programming-teaching guidelines in our education system today (keep in mind, this is an educated opinion of my own, feel free to disagree).

*Stops self from going into philosophical debate on today's education system*

Good luck with your program and sorry if I went a bit too far with this post,
-blazed
Jun 4 '07 #30
So no one likes my mini putt idea i thought it was pritty cool
Jun 4 '07 #31
nomad
664 Expert 512MB
Your abilities reflect poorly on your teacher. Your misunderstanding as to why he didn't "like the idea of hangman" only worsens his image.

Unfortunately, I don't know the nature of this assignment, nor what goals this teacher has in teaching you java. It's only frustrating because you (and many people here) contributed much effort into procuring this project (and we barely scratched its surface. It really seemed like you could have learned a lot from the process. But now you will move on to something relatively unimportant just because the teacher might like the idea of visualizing golf balls.

In my educated opinion mini-put stresses syntax (java visual/GUI specifics, the not-so-important step in programming) and ignores problem-solving/logic puzzles (the HOW do you do this or that, the psuedocode that is so hard for people to think up when they first start programming).

This is the very problem with most programming-teaching guidelines in our education system today (keep in mind, this is an educated opinion of my own, feel free to disagree).

*Stops self from going into philosophical debate on today's education system*

Good luck with your program and sorry if I went a bit too far with this post,
-blazed
All well..I started some reseach on this one, that's ok, the next person that comes along and is looking for help will still get help from me on Hangman.
Good luck with game...
nomad
Jun 4 '07 #32
DeMan
1,806 1GB
good on you, nomad!!!
Jun 4 '07 #33
so no one can help me find a way to get em both to pop up and how to get the ball to move?
Jun 4 '07 #34
blazedaces
284 100+
so no one can help me find a way to get em both to pop up and how to get the ball to move?
I don't know what you mean exactly by "pop up". Do you mean appear on the screen, the image that is? Or do you mean pop out of the hole? I don't know, confusing, sorry.

As for getting a ball to move

Ask yourself how you would have to draw a straight line from where it starts to where it finishes. Again, just like with the hangman advice, take this ONE STEP AT A TIME.

Ok, trigonometry, you know how mini-put games somewhat look like (go an play one online if you don't). They let you point where you want it shot and how "hard" you want to shoot it (the position and force).

Starting to sound like a physics problem right? So you get the position, which is really probably being represented by a distance and angle relative to some axis (sounds like a polar coordinate right?) and the force which equals mass times acceleration (mass which you specified already).

Then ask, well, how do I make it move the way it would in the real world with this knowledge? Its acceleration,velocity, and position would be calculations based on basic Newtonian physics right?

Start with getting those numbers. It should allow you to calculate how far it goes, how long it's going that far, how fast it should be at any point, etc.

Once you have that (take it in as many individual steps at a time) come back and let's think of how to make it appear as fast as it's going, etc. Alright?

Good luck dude,

-blazed
Jun 4 '07 #35
I don't know what you mean exactly by "pop up". Do you mean appear on the screen, the image that is? Or do you mean pop out of the hole? I don't know, confusing, sorry.

As for getting a ball to move

Ask yourself how you would have to draw a straight line from where it starts to where it finishes. Again, just like with the hangman advice, take this ONE STEP AT A TIME.

Ok, trigonometry, you know how mini-put games somewhat look like (go an play one online if you don't). They let you point where you want it shot and how "hard" you want to shoot it (the position and force).

Starting to sound like a physics problem right? So you get the position, which is really probably being represented by a distance and angle relative to some axis (sounds like a polar coordinate right?) and the force which equals mass times acceleration (mass which you specified already).

Then ask, well, how do I make it move the way it would in the real world with this knowledge? Its acceleration,velocity, and position would be calculations based on basic Newtonian physics right?

Start with getting those numbers. It should allow you to calculate how far it goes, how long it's going that far, how fast it should be at any point, etc.

Once you have that (take it in as many individual steps at a time) come back and let's think of how to make it appear as fast as it's going, etc. Alright?

Good luck dude,

-blazed


Ok thanks alot man that is very helpfull as for what i mean by the pop up i have a picutre of a gold ball and a course when i label them both only the ball pops up if i label the course only the course pops up how do i get it so the ball appears on the start of the course?like i can only get one of em to pop up at a time even tho i label them both you no what i mean?
Jun 5 '07 #36
i cant figure out how to get the gold ball to appear on the golf course only one image pops up lol if anyone nos what i mean please post a way to get the ball on the course thanks


import javax.swing.*;
import java.awt.*;
public class FristPanel
{
public static void main(String args [])
{
JFrame jf1 = new JFrame("This Is the First Frame");
JLabel lbl1 = new JLabel();
JLabel lbl2 = new JLabel();
jf1.setSize(500,500);
Container c = jf1.getContentPane();



ImageIcon icon = new ImageIcon("Golf.jpg");
lbl1.setIcon(icon);

c.add(lbl1);

ImageIcon icon2 = new ImageIcon("golfball.jpg");
lbl2.setIcon(icon2);

c.add(lbl2);

jf1.setVisible(true);

}
}
Jun 5 '07 #37
blazedaces
284 100+
i cant figure out how to get the gold ball to appear on the golf course only one image pops up lol if anyone nos what i mean please post a way to get the ball on the course thanks


import javax.swing.*;
import java.awt.*;
public class FristPanel
{
public static void main(String args [])
{
JFrame jf1 = new JFrame("This Is the First Frame");
JLabel lbl1 = new JLabel();
JLabel lbl2 = new JLabel();
jf1.setSize(500,500);
Container c = jf1.getContentPane();



ImageIcon icon = new ImageIcon("Golf.jpg");
lbl1.setIcon(icon);

c.add(lbl1);

ImageIcon icon2 = new ImageIcon("golfball.jpg");
lbl2.setIcon(icon2);

c.add(lbl2);

jf1.setVisible(true);

}
}
Here, take a look at this: http://java.sun.com/docs/books/tutor...ents/icon.html

It literally explains how to put multiple icons on the frame.

Good luck man,

-blazed
Jun 5 '07 #38
Here, take a look at this: http://java.sun.com/docs/books/tutor...ents/icon.html

It literally explains how to put multiple icons on the frame.

Good luck man,

-blazed

there using imageicons tho im useing Jlabels? arnt i?
Jun 5 '07 #39
blazedaces
284 100+
there using imageicons tho im useing Jlabels? arnt i?
Look, did you do it or not? Just please try doing the entire tutorial. Then after that, try doing some that relate.

After that come back ok...

-blazed
Jun 5 '07 #40
Look, did you do it or not? Just please try doing the entire tutorial. Then after that, try doing some that relate.

After that come back ok...

-blazed

lol i Cant figure it out i read it all tryed to do it in my project not working out tho
so im back with this

import javax.swing.*;
import java.awt.*;
public class FristPanel
{
public static void main(String args [])
{
JFrame jf1 = new JFrame("This Is the First Frame");
JLabel lbl1 = new JLabel();
JLabel lbl2 = new JLabel();


jf1.setSize(500,500);
Container c = jf1.getContentPane();


ImageIcon icon = new ImageIcon("Golf.jpg");
lbl1.setIcon(icon);

c.add(lbl1);

ImageIcon icon2 = new ImageIcon("golfball.jpg");
lbl2.setIcon(icon2);



c.add(lbl2);
c.add(lbl1);

jf1.setVisible(true);



}
}


I just need the golf ball to pop up on the course i got the ball where i want it to pop up but now the course wont pop up in back can u try loading that code so u get a idea of what i mean maybe u will no the problem
Ps; the gold course is just a rectangle for now i want to make a course thats just stright then move up
Jun 5 '07 #41
Like i no its just a simple thing i need to add i just cant figure out what and i need it for tommoro cause its half of its due so im kind of pannincing lol
Jun 5 '07 #42
blazedaces
284 100+
lol i Cant figure it out i read it all tryed to do it in my project not working out tho
so im back with this
Ok, sorry, I'm trying to be patient as best I can. I hope I don't let myself go too far again.

Listen, when you go to use a tutorial to help you out with something that is not working, what do you do? You read it, right? You know that the tutorial is the absolute correct way of doing things, so go through the following conversation style in your head:

I know the tutorial is right and I know that I'm wrong. Therefore, we must be different.

So... what is different?! Of course, the difference, that must be what I should look for.

Now, if I can understand that difference then I will understand why my way is incorrect.

Try again please, I want you to learn how to do this yourself because this process is a very large part in programming and becoming a good programmer.

Good luck,

-blazed
Jun 5 '07 #43
Yea but when i do it how they say i get loads of errors and i cant figure them out at all thats my problem but the way im doing it i just need a line of code that will let the other image go on the screen thats what one of my buds told me but we dont no what to add that will allow it to
Jun 5 '07 #44
blazedaces
284 100+
Yea but when i do it how they say i get loads of errors and i cant figure them out at all thats my problem but the way im doing it i just need a line of code that will let the other image go on the screen thats what one of my buds told me but we dont no what to add that will allow it to
Figuring out those errors will make that line of code all but obvious. It's part of the process. What errors are you getting?

-blazed
Jun 5 '07 #45
Figuring out those errors will make that line of code all but obvious. It's part of the process. What errors are you getting?

-blazed
/

Will First sis i add it in right?


import javax.swing.*;
import java.awt.*;
public class BackUp
{
public static void main(String args [])
{
JFrame jf1 = new JFrame("This Is the First Frame");
JLabel lbl1 = new JLabel();
JLabel lbl2 = new JLabel();


jf1.setSize(500,500);
Container c = jf1.getContentPane();

ImageIcon icon = createImageIcon("golf.jpg",
"a pretty but meaningless splat");
label1 = new JLabel("Image and Text", icon, JLabel.CENTER);

label2 = new JLabel(golfball.jpg);

protected static ImageIcon createImageIcon(String path,
String description) {
java.net.URL imgURL = LabelDemo.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}


c.add(lbl2);
c.add(lbl1);

jf1.setVisible(true);



}
}
Jun 5 '07 #46
blazedaces
284 100+
/

Will First sis i add it in right?


import javax.swing.*;
import java.awt.*;
public class BackUp
{
public static void main(String args [])
{
JFrame jf1 = new JFrame("This Is the First Frame");
JLabel lbl1 = new JLabel();
JLabel lbl2 = new JLabel();


jf1.setSize(500,500);
Container c = jf1.getContentPane();

ImageIcon icon = createImageIcon("golf.jpg",
"a pretty but meaningless splat");
label1 = new JLabel("Image and Text", icon, JLabel.CENTER);

label2 = new JLabel(golfball.jpg);

protected static ImageIcon createImageIcon(String path,
String description) {
java.net.URL imgURL = LabelDemo.class.getResource(path);
if (imgURL != null) {
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}


c.add(lbl2);
c.add(lbl1);

jf1.setVisible(true);



}
}
Look, I'm by far not an expert on Java GUI's, but I've made GUI's in other programming languages. Take another look at the java tutorials and also take a look at the container class documentation because I believe you're not using a Layout and that might be the problem.

Tell me if this gets you anywhere.

-blaze
Jun 5 '07 #47
wait i cleaned it up a lil this is what i got 8 errors tho


import javax.swing.*;
import java.awt.*;
public class BackUp
{
public static void main(String args [])
{
JFrame jf1 = new JFrame("This Is the First Frame");
JLabel lbl1 = new JLabel();
JLabel lbl2 = new JLabel();


jf1.setSize(500,500);
Container c = jf1.getContentPane();

ImageIcon icon = createImageIcon("golf.jpg");

JLabel1 = new JLabel("Image and Text", icon, JLabel.CENTER);

JLabel2 = new JLabel(golfball.jpg);

protected static ImageIcon createImageIcon(String path,String description)
{
java.net.URL imgURL = golfball.jpg(path);
if (imgURL != null)
{
return new ImageIcon(imgURL, description);
}
else
{
System.err.println("Couldn't find file: " + path);
return null;
}
}


c.add(lbl2);
c.add(lbl1);

jf1.setVisible(true);



}
}
Jun 5 '07 #48
Look, I'm by far not an expert on Java GUI's, but I've made GUI's in other programming languages. Take another look at the java tutorials and also take a look at the container class documentation because I believe you're not using a Layout and that might be the problem.

Tell me if this gets you anywhere.

-blaze
what u mean container class documentation
Jun 5 '07 #49
Wait down to 2 errors !!! :D ok it says illegal start of expression and class ubterface or enum expected heres my code ! :D

protected static ImageIcon createImageIcon(String path,String description
(Thats where the illgal start of expression is)


import javax.swing.*;
import java.awt.*;
import javax.swing.JLabel;
public class MiniPutt

{
public static void main(String args [])
{
JFrame jf1 = new JFrame("This Is the First Frame");
JLabel lbl1 = new JLabel();
JLabel lbl2 = new JLabel();


jf1.setSize(500,500);
Container c = jf1.getContentPane();

ImageIcon icon = createImageIcon("golf.jpg");

JLabel1 = new JLabel("Image and Text", icon, JLabel.CENTER);

JLabel2 = new JLabel(golfball.jpg);

protected static ImageIcon createImageIcon(String path,String description)
{
java.net.URL imgURL = golfball.jpg(path);
if (imgURL != null)
{
return new ImageIcon(imgURL, description);
}
else
{
System.err.println("Couldn't find file: " + path);
return null;
}
}


}
}
Jun 5 '07 #50

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: tigrfire | last post by:
So I'm trying to write a hangman game and the output is coming out a little strange. Here's my code thus far: #include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> ...
18
ilikepython
by: ilikepython | last post by:
Hi I'm new to Python(3 to 4 days) and I'm working on a hangman game and have been having some problems that really annoy me. Here is part of my script: c = input('Would you like to play hangman?...
4
by: princessfrost | last post by:
Hi! I was wondering if someone could please help me with a hangman program that I have to do. I have some ideas, but really don't know what to do or where to start. My program needs to be:...
2
by: tesa | last post by:
I am not able to figure out how to make this work. I am trying to create a hangman game. I am in a basic javascripting class. I am to only use very basic code as you can see. I am able to use any...
5
by: av3rage | last post by:
I have never done any programming in my life but I have decided to go into engineering and in doing so we have to take this intro to programming course and I am pretty clueless. I am starting to get...
8
by: tidiz | last post by:
Hi, I'm trying to make a hangman game that should look like this: Welcome to Hangman ______ Your guess: c Success! __cc__ Your guess: b
1
by: AlexSc | last post by:
Hi to All, I am doing on a hangman project, Where this is a very simple one, where player would guess the word and if it is correct the letter would be from "-" to the correct letter once all...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.