package class10_3_VirtualProxy; import javax.swing.*; import java.io.IOException; import java.net.URL; /** * A basic image viewing application * @author hornick */ public class ImageViewer extends JFrame { // a UI component that contains the image private ImageComponent imageComponent; public static void main(String[] args){ ImageViewer iv = new ImageViewer(); iv.initUI(); } // init the UI for this app private void initUI() { setTitle("Image Viewer"); Icon icon = null; // try { // TODO: where to do this? // } catch (Exception e) { // // TODO Auto-generated catch block // e.printStackTrace(); // System.exit(0); // } try { // TODO: Replace with a picture that DOES take a long time to load. // http://earthobservatory.nasa.gov/Features/NightLights/page3.php // http://eoimages.gsfc.nasa.gov/images/imagerecords/79000/79765/dnb_land_ocean_ice.2012.13500x6750.jpg -- sometimes loads on campus // http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73580/world.topo.bathy.200401.3x21600x21600.C2.jpg -- fails to load from home machine // http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73580/world.topo.bathy.200401.3x21600x10800.jpg -- also fails to load // https://www.google.com/search?q=very+high+resolution+image+earth&source=lnms&tbm=isch&sa=X&ved=0ahUKEwid0cGXkYDLAhVhmoMKHR72B54Q_AUIBygB&biw=1270&bih=865#q=very+high+resolution+image+earth&tbm=isch&tbs=isz:lt,islt:70mp&imgrc=8jYzHBBfu11rKM%3A // URL url = new URL("http://assets.overclock.net.s3.amazonaws.com/f/f7/f740be93_vbattach181511.jpeg"); URL url = new URL("http://eoimages.gsfc.nasa.gov/images/imagerecords/79000/79765/dnb_land_ocean_ice.2012.13500x6750.jpg"); // URL url = new URL("http://eoimages.gsfc.nasa.gov/images/imagerecords/73000/73580/world.topo.bathy.200401.3x21600x10800.jpg"); icon = new ImageProxy(url,this); } catch (IOException e) { e.printStackTrace(); //TODO: change body of catch statement use File | Settings | File Templates. } setSize(icon.getIconWidth() + 800,icon.getIconHeight() + 100); // set the window size imageComponent = new ImageComponent(icon); // add the icon to the canvas getContentPane().add(imageComponent); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } }