I am trying to create a chess game for java using images my classmate and I are working on. We are using a created image to serve as the board and pieces to place about that the user can drag and place. Unfortunately we do not currently know how to import images from a file directory into the program itself. Not only that, but we are completely clueless as to why this would occur, as the Java API guide does not clearly explain this process.
+2
A:
The portion of the JDK API that provides image input is the package javax.imageio. The easiest way to load an image (into a BufferedImage object) is:
BufferedImage img = ImageIO.read( new File(pathname) );
Don't forget to catch the appropriate exceptions.
RD
2010-10-22 15:55:27
+1
A:
Read the section from the Swing tutorial on How to Use Icons for working examples of different ways to read images and display them on a label. Its easier to drag a label around the screen then just and image.
camickr
2010-10-22 16:09:12