package class3_2_BigImage;// Dr. Yoder. MSOE. 13 December 2016 import javax.swing.*; import java.awt.*; public class ImageViewer extends JFrame { // a UI component that contains the image private BigImage 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"); setSize(640,480); System.out.println("Scroll pane added"); JPanel imageHolder = new JPanel(new BorderLayout()); imageHolder.add(imageComponent,BorderLayout.CENTER); imageHolder.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); JScrollPane pictureScrollPane = new JScrollPane(imageHolder,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); add(pictureScrollPane); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } }