Computer Science Canada importing a picture from a file and printing it out into a window |
Author: | tenniscrazy [ Sun May 25, 2008 5:05 pm ] | ||
Post subject: | importing a picture from a file and printing it out into a window | ||
I need to learn how to do this..i know it's pretty basic and ply easy, but i have been trying for a couple days now and have gotten nowhere. As far as i can tell there are a number of ways to import pictures into a program. I found one that looks relatively simple, and i understand it well enuf. Could someone please tell me what i did wrong to implement it plz
|
Author: | HellblazerX [ Mon May 26, 2008 12:38 pm ] | ||||
Post subject: | Re: importing a picture from a file and printing it out into a window | ||||
Shouldn't this:
be this:
|
Author: | tenniscrazy [ Tue May 27, 2008 7:53 am ] | ||
Post subject: | Re: importing a picture from a file and printing it out into a window | ||
thanks, that works. but this part of the code keeps giving me various errors
it says illigal start of type for the try line it also gives an error for the command 'File' I have tried various things but all the stuff i found said it should be exactly like this |
Author: | HellblazerX [ Tue May 27, 2008 8:03 am ] | ||
Post subject: | Re: importing a picture from a file and printing it out into a window | ||
You need to import the ImageIO and File classes:
|
Author: | tenniscrazy [ Wed May 28, 2008 7:41 am ] |
Post subject: | RE:importing a picture from a file and printing it out into a window |
AH!!! i got the first one but i had no idea about the second one. OK it should work now...hopefully |
Author: | tenniscrazy [ Mon Jun 02, 2008 8:37 am ] |
Post subject: | RE:importing a picture from a file and printing it out into a window |
so i found code that works in the java almanac. It compiles fine, but when i try to run it it the window comes up and it doesn't print the picture, it just compies the image that is behind it on the monitor. Could this be a problem with the computer i'm using, or is it something thats wrong with the code again? |
Author: | HellblazerX [ Mon Jun 02, 2008 3:59 pm ] |
Post subject: | Re: importing a picture from a file and printing it out into a window |
You're drawing your picture before you draw your background, so your background is covering up your picture. Just reverse the order and you should be fine. |
Author: | tenniscrazy [ Mon Jun 02, 2008 6:34 pm ] |
Post subject: | RE:importing a picture from a file and printing it out into a window |
my picture is my background. what i meant is that its copying the background of my desktop and putting it in the window, so it's like see-through exept when you move the window around it keeps the picture of the desktop it started with. Like when a computer is being laggy and you try and open a minimized window and it does the same thing Edit: nevermind i got it to work |