Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud
this week in the
Cloud/Virtualization
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Paul Clapham
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Saloon Keepers:
Tim Holloway
Carey Brown
Roland Mueller
Piet Souris
Bartenders:
Forum:
Swing / AWT / SWT
problem with load image file
Alex Florentino
Ranch Hand
Posts: 48
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
what is the problem with this code ? I need load image file(java.awt.Image) the image be in local machine:
package test; import java.awt.*; import java.io.File; import java.net.MalformedURLException; import java.net.URL; public class Image2 { public static void main(String[] args) throws InterruptedException, MalformedURLException { String filePath = "test.gif"; File file = new File(filePath); System.out.println(file.exists()); Image im = Toolkit.getDefaultToolkit().createImage(filePath); System.out.println(im.toString()); MediaTracker mediaTracker = new MediaTracker(new Container()); mediaTracker.addImage(im, 0); mediaTracker.waitForAll(); System.out.println("Houve erro:"+(mediaTracker.statusID(0, false) == MediaTracker.ERRORED)); System.out.println("SIZE:"+im.getWidth(null)+"-"+im.getHeight(null)); } }
thanks
Craig Wood
Ranch Hand
Posts: 1535
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I used an image file located in the current directory and your code loaded it okay.
I got this output in the console:
C:\jexp>java I2Test true sun.awt.image.ToolkitImage@18020cc Houve erro:false SIZE:560-320
If the image file is not in the current directory then there are some other things
we can do to load it.
Alex Florentino
Ranch Hand
Posts: 48
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
the issue was image, I change image and works.
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Java Forums - Image only shows after screen is reloaded (hidden and showed again)
urgency!!! In Japplet, how to make......
Building a splash screen
Loading image in Canvas (Urgent)
Displaying Photo's with Frame GUI
More...