I am trying to get
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
I am trying to get
Last edited by stresstedout; March 4th, 2014 at 01:50 AM.
For better help sooner, post an SSCCE demonstrating exactly what you're doing. If you're having trouble displaying more than one image, your example should be code that tries to show two images.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
rather than telling me what to post and what not to why dont u just help!! man all u people on these forums just know how to upset and make someone feel horrible.
i have been trying to do this for days now, i have tired a while loop, i have also tried to override each previous value, and use the last to set the image but im just confused!! so if u have somthing that can help me then please or just dont comment
The code you posted is impossible to debug. It's too small of a window into what you're actually doing, and it includes stuff that has nothing to do with your problem. That's why I asked for an SSCCE. Isolating the problem is a fundamental skill to have when programming, and half the time you'll find the problem yourself during the process of creating the SSCCE. If you provide that, I'd be happy to help. This is a technical forum, so we don't have a lot of room for tantrums and whining. It's up to you how to proceed from here.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
i am makin a
Last edited by stresstedout; March 4th, 2014 at 01:50 AM.
When posting code, please use the highlight tags to preserve formatting. Also, I recommend using standard naming conventions- classes start with upper-case letters, methods and variables start with lower-case letters.
And like I said, the name of the game is "isolating the problem". Which part of this is breaking? Reading from the database, or displaying the images? Can you read images from hardcoded file paths? Can you display those hardcoded images, without trying to load from a database? Separately, can you load from a database without displaying the images? You have to isolate the problem down to its smallest piece. That's why it's recommended that you code one small piece of your program at a time instead of trying to code the whole thing at once and then hoping for the best.
So I would say your next step is to isolate the problem: which part is giving you trouble, loading from the database or displaying images?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Displaying the images is my problem
Last edited by stresstedout; March 4th, 2014 at 01:50 AM. Reason: update
Andrea, www.andbin.net — SCJP 5 (91%) – SCWCD 5 (94%)
Useful links for Java beginners – My new project Java Examples on Google Code
how am i able to display imagess from the database in labels to jframe?
i think im cofused, i been tryiing to fix it but getting no were.
Andrea, www.andbin.net — SCJP 5 (91%) – SCWCD 5 (94%)
Useful links for Java beginners – My new project Java Examples on Google Code
are you able to give me an example?
while (result.next()) { image = result.getBytes("content"); } // Here you have exausted the record-set. And you have not created any image (just got the raw image stream). // Here you create 1 Image only, with the last image stream. Image img = Toolkit.getDefaultToolkit().createImage(image);
Andrea, www.andbin.net — SCJP 5 (91%) – SCWCD 5 (94%)
Useful links for Java beginners – My new project Java Examples on Google Code
so i need to add a url?
No. You need to understand how scope and assignment works. For example:
int x = 0; for(int i = 0; i < 10; i++){ x = i; } System.out.println(x);
According to your code, x should print 0-9, which obviously isn't true.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
now im seriously confused!
Each time the bytes for an image are stored in the image array, the code must make an image from those bytes. Otherwise only the bytes for the last image are in the image array when an image is made from those bytes. All the previously read bytes are gone.
If you don't understand my answer, don't ignore it, ask a question.
i have been trying to do this for 2 weeks now, not getting no were. i cnt do it. ta anyways
That's the spirit!
Instead of giving up, trace through your program logically. Let's say your results are ImageOne, ImageTwo, and ImageThree.
You get the first result, then set image equal to ImageOne. You then loop and set image equal to ImageTwo. Then you loop again and set image equal to ImageThree. Notice that you haven't done anything with ImageOne or ImageTwo!
You then exit the loop and do something with image, which is still set to ImageThree. Your question is about why ImageOne and ImageTwo are being ignored, and the answer is because you are ignoring them.
That's why I asked you to break down your problem: your first problem has nothing to do with displaying images, and has only to do with fetching results from a database. Even simpler than that, your problem is with scope and assignment, which we've explained a couple of different ways now.
I can't stop you from giving up, but the act of narrowing down your problem and focusing on one small piece at a time *is* programming. I recommend starting with a smaller program, maybe one that just gets a List of results from a database and prints them out?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
\rrrgh
Last edited by stresstedout; March 4th, 2014 at 01:51 AM. Reason: UPDATE
What does the code do with the contents of the image array after it is given a value inside the loop?
The contents of the image array is what is needed to create an Image object with the createImage() method.
If you don't understand my answer, don't ignore it, ask a question.
sir i really am stuck, ive been trying to figure this out all day now and its 1am, please help me im confused
Last edited by stresstedout; March 4th, 2014 at 01:51 AM. Reason: update
Can you describe in English what the program should do with the bytes it reads into the image array in posts #7 and #19?
Every time around the loop a new set of bytes is read into the image array.
What needs to be done each time some bytes are read into the array?
I have no idea what the posted code in #21 has to do with your current problem.
If you don't understand my answer, don't ignore it, ask a question.
i am makin a match game,in order to do that i have been trying to add image to my sql database which i have completed, those images which are in the database i would like them to be on a jframe in jlabels and have buttons on top so so i click the button the image shows under, and u press another button and the image shows if they match they stay up right if not go back to nomal.
The problem i have i was able to get the code working for displaying 1 image but i cnt do more than 1.. i need 20 images to be displayed from the database
Right now work on making images from the bytes returned by the getBytes() method. Save working on the other details for later. Work on One problem at a time.
Can you describe in English what the program should do with the bytes it reads into the image array in posts #7 and #19?
Every time around the loop a new set of bytes is read into the image array.
What needs to be done each time some bytes are read into the array?
How many times does the code go around the while() loop? Add a println() statement inside the loop so you can see how many times the loop is executed.
That will tell you how many images are being returned.
If you don't understand my answer, don't ignore it, ask a question.
forget it man!!