import java.awt.Color; import java.io.File; import java.io.IOException; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import princeton.Picture; /** * Starter class for Compsci 100, Fall 2009, Steganography Assignment * * @author YOUR_NAME_HERE * */ public class HideImage { protected static JFileChooser ourOpenChooser = new JFileChooser(System .getProperties().getProperty("user.dir")); public static void main(String[] args) throws IOException { String fname = null; String gname = null; ourOpenChooser.setDialogTitle("Choose target image file to hide in"); int action = ourOpenChooser.showOpenDialog(null); if (action == JFileChooser.APPROVE_OPTION) { File f = ourOpenChooser.getSelectedFile(); fname = f.getCanonicalPath(); } else { System.exit(1); } ourOpenChooser.setDialogTitle("Choose source image file to hide"); action = ourOpenChooser.showOpenDialog(null); if (action == JFileChooser.APPROVE_OPTION) { File f = ourOpenChooser.getSelectedFile(); gname = f.getCanonicalPath(); } if (fname != null && gname != null) { String sbits = JOptionPane.showInputDialog( "# bits used for hiding", "2"); int bits = Integer.parseInt(sbits); Picture target = new Picture(fname); Picture source = new Picture(gname); target.show(); source.show(); HideImage hider = new HideImage(); } } }