Mega Code Archive

 
Categories / Java / 2D Graphics GUI
 

Reading an Image or Icon from a File

import java.awt.Image; import java.awt.Toolkit; public class BasicDraw {   public static void main(String[] args) {     Image image = Toolkit.getDefaultToolkit().getImage("image.gif");     int width = image.getWidth(null);     int height = image.getHeight(null);     if (width >= 0) {       // The image has been fully loaded     } else {       // The image has not been fully loaded     }   } }