austin123
asked on
Problem With Image Data And getImage(...) Function
Hi Experts,
Whether you open accidently say a .txt file in Image data using getImage(..) or whatever the case is this method always and immediately returns non-null. Even if the image is not FULLY AND SUCCESSFULLY loaded but because of this function immediate returning of non-null value, you can't trace whether there is really image data or whether the image is successfully and fully loaded or not.
I have also use mediatracker with th images after calling getImage(..), and used the mediatracker waitforAll() methods but many times mostly when number of images are more, it too doesn't give the desired results.
Is there any way that the control of the java-applet program doesn't go any further unless an until the Image gets fully and successfully loaded.
In my applet there are 15-20 jpeg's (not big), but always two or three are left out giving a bad view of the applet to the end user.
Best Regards
Austin
Whether you open accidently say a .txt file in Image data using getImage(..) or whatever the case is this method always and immediately returns non-null. Even if the image is not FULLY AND SUCCESSFULLY loaded but because of this function immediate returning of non-null value, you can't trace whether there is really image data or whether the image is successfully and fully loaded or not.
I have also use mediatracker with th images after calling getImage(..), and used the mediatracker waitforAll() methods but many times mostly when number of images are more, it too doesn't give the desired results.
Is there any way that the control of the java-applet program doesn't go any further unless an until the Image gets fully and successfully loaded.
In my applet there are 15-20 jpeg's (not big), but always two or three are left out giving a bad view of the applet to the end user.
Best Regards
Austin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks heyhey and bpouydog,
I will explain you things now after 4 days of long work. I too believed that mediatracker cannot work in a wrong way as you also quoted heyhey, But still the following problem is occuring with my code.
I have 8 buttons on my applet and each button has image(gif) over it, my code all in the init() method::
url1=getClass().getResourc e("button1 .gif");
button1gif=getImage(url1);
url1=getClass().getResourc e("button2 .gif");
button2gif=getImage(url1);
..... for all eight gif's, then
mediatracker1.addImage(but ton1gif,0) ;
mediatracker1.addImage(but ton2gif,1) ;
....... for all eight,then
try
{
mediatracker1.waitForAll() ;
}catch(InterruptedExceptio n e)
{
}
if (mediatracker1.isErrorAny( )==true)
System.out.println("Yes Errors");
else
System.out.println("No Errors");
Console Prints that there are No Errors, after which I create buttons as ::
JButoon button1=new JButton(button1gif)
..... and so on for the rest buttons
But the gif's can be seen only in the last four buttons and not the first four. No doubt, apart from these images there are some more images which gets downloaded for my applet to work. But for all I have used the same technique ..
waitforall() and IsErrorAny(), and everywhere I gets "No ERROR". Rest all images are fine. The problem is with the gif's of the FIRST FOUR BUTTONS. ALSO THE PROBLEM IS NOT ALWAYS. FEW TIMES THEY ALL GETS DOWNLOADED say 1 out of 4.
I don't know why this is happening, Please see to it.
Best Regards
Austin
I will explain you things now after 4 days of long work. I too believed that mediatracker cannot work in a wrong way as you also quoted heyhey, But still the following problem is occuring with my code.
I have 8 buttons on my applet and each button has image(gif) over it, my code all in the init() method::
url1=getClass().getResourc
button1gif=getImage(url1);
url1=getClass().getResourc
button2gif=getImage(url1);
..... for all eight gif's, then
mediatracker1.addImage(but
mediatracker1.addImage(but
....... for all eight,then
try
{
mediatracker1.waitForAll()
}catch(InterruptedExceptio
{
}
if (mediatracker1.isErrorAny(
System.out.println("Yes Errors");
else
System.out.println("No Errors");
Console Prints that there are No Errors, after which I create buttons as ::
JButoon button1=new JButton(button1gif)
..... and so on for the rest buttons
But the gif's can be seen only in the last four buttons and not the first four. No doubt, apart from these images there are some more images which gets downloaded for my applet to work. But for all I have used the same technique ..
waitforall() and IsErrorAny(), and everywhere I gets "No ERROR". Rest all images are fine. The problem is with the gif's of the FIRST FOUR BUTTONS. ALSO THE PROBLEM IS NOT ALWAYS. FEW TIMES THEY ALL GETS DOWNLOADED say 1 out of 4.
I don't know why this is happening, Please see to it.
Best Regards
Austin
can you post the whole code and preferebly the compiled applet on some URL that we can access ?
Greetings,
This question is still open today. Perhaps it was overlooked. If you've been helped, just choose the expert's comment which served your needs as the accepted answer to then grade and close. If more is needed, please advise.
Your responsiveness is appreciated.
Asta
This question is still open today. Perhaps it was overlooked. If you've been helped, just choose the expert's comment which served your needs as the accepted answer to then grade and close. If more is needed, please advise.
Your responsiveness is appreciated.
Asta
austin123----> You have asked 30 question at this site and only graded 19, this is unacceptable.
Please check the Help Desk link on the left about site-related guidelines and the Member Agreement.
I will update all your open questions and monitor them for closure. Please remain active in all your open questions, provide feedback to the expert who help you and when the process is complete, award the expert(s) with points. If you need help in this regard, post a zero point question in Community Support topic area with question link and request.
Experts, please let me know your recommendations as to the fair outcome of this question if Asker chooses not to finalize this.
Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
Please check the Help Desk link on the left about site-related guidelines and the Member Agreement.
I will update all your open questions and monitor them for closure. Please remain active in all your open questions, provide feedback to the expert who help you and when the process is complete, award the expert(s) with points. If you need help in this regard, post a zero point question in Community Support topic area with question link and request.
Experts, please let me know your recommendations as to the fair outcome of this question if Asker chooses not to finalize this.
Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
Expert input is welcome here, since it is clear that austin123 is not returning to finalize open questions as to a fair outcome and to ensure the quality we want enters the PAQ.
Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
Austin has indicated in another question that the intention is to return and update all open questions.
Thanks for your patience, all.
Moondancer
Community Support Moderator @ Experts Exchange
Thanks for your patience, all.
Moondancer
Community Support Moderator @ Experts Exchange
Please let the experts know here about the results of their recommendations made to you. If more than one helped you, I can split the points to those who did. Just comment here with details.
Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
Thanks,
Moondancer
Community Support Moderator @ Experts Exchange
I've NEVER HAD ANY problems with MediaTracker. please post your code.