You are on page 1of 5

/* *@author William_Wilson *@version 1.0 *Created May 10, 2007 */ /* *Import List */ import java.awt.Color; import java.

awt.Insets; import java.awt.Container; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import import import import import import import import import import import javax.swing.JMenu; javax.swing.JFrame; javax.swing.JPanel; javax.swing.JLabel; javax.swing.JButton; javax.swing.JMenuBar; javax.swing.JMenuItem; javax.swing.JTextArea; javax.swing.JScrollBar; javax.swing.JScrollPane; javax.swing.BorderFactory;

/* *Class Steganography_View */ public class Steganography_View extends JFrame { //sie variables for window private static int WIDTH = 500; private static int HEIGHT = 400; //elements for JPanel private JTextArea private JScrollBar private JButton private JLabel //elements for Menu private JMenu private JMenuItem private JMenuItem private JMenuItem input; scroll,scroll2; encodeButton,decodeButton; image_input; file; encode; decode; exit;

/* *Constructor for Steganography_View class *@param name Used to set the title on the JFrame */ public Steganography_View(String name) { //set the title of the JFrame super(name); //Menubar JMenuBar menu = new JMenuBar();

// display rules setResizable(true). file.setMnemonic('F'). exit.//what to do on close operation: exit. setJMenuBar(menu). decode. { return exit.addSeparator(). //allow window to be resized: true?false setBackground(Color.name setLocation(100. menu. //locati on on the screen to display window setDefaultCloseOperation(EXIT_ON_CLOSE). add(decode). file. //background col or of window: Color(int. } /* *@return The JPanel displaying the Encode View */ public JPanel getTextPanel() { return new Text_Panel(). add(encode).setMnemonic('D'). //show t he window: true?false } /* *@return The menu item 'Encode' */ public JMenuItem getEncode() } /* *@return The menu item 'Decode' */ public JMenuItem getDecode() } /* *@return The menu item 'Exit' */ public JMenuItem getExit() } /* *@return The TextArea containing the text to encode */ public JTextArea getText() { return input.HEIGHT).int.add(ex it).setMnemonic('x'). file. exit = new JMenuItem("Exit"). //set the size o f the window setVisible(true). file. do_nothing.JMenu file = new JMenu("File"). encode = new JMenuItem("Encode"). decode = new JMenuItem("Decode"). } /* *@return The JLabel containing the image to decode text from */ public JLabel getImageInput() { return image_input.add(file). . { return decode.100).lightGray). encode.setMnemonic('E'). file. } /* *@return The JPanel displaying the Decode View { return encode. etc setSize(WIDTH.int) or Color.

gridh eight = 1.weightx .gridx = 0.0.0.insets layoutConstraints.-5. /* *Class Text_Panel */ private class Text_Panel extends JPanel { /* *Constructor to enter text to be encoded */ public Text_Panel() { //setup GridBagLayout GridBagLayout layout = new GridBagLayout().anchor = GridBagConstraints. /* *@return The Encode button */ public JButton getEButton() } /* *@return The Decode button */ public JButton getDButton() } { return encodeButton. layoutConstraints. layoutConstraints. encodeButton = new JButton("Encode Now"). setLayout(layout).gridwidth = 1.0. layoutConstraints. layoutConstraints.weighty = 50.BOT = 0.gridy = 1 .*/ public JPanel } getImagePanel() { return new Image_Panel().V ERTICAL_SCROLLBAR_AS_NEEDED. layoutConstraints. layoutConstraints.1)). GridBagConstraints layoutConstraints = new GridBagConstr aints(). layoutConstraints.HORIZONTAL_SCROLLBAR_AS_NEEDED). layoutConstraints.CEN = new Insets(0.-5. { return decodeButton. JScrollPane scroll = new JScrollPane(input.CEN = GridBagConstraints.BOT = 1. add(scroll). layout.0).insets . layoutConstraints. layoutConstraints. JScrollPane.-5) = GridBagConstraints.0. input = new JTextArea().anchor TER. layoutConstraints = new Insets(0.createLineBorder(Color.gridwidth = 1.setConstraints(scroll.JScrollPane. layoutConstraints.gridh eight = 1.fill H. = GridBagConstraints.BL ACK. scroll. layoutConstraints. layoutConstraints.g .setBorder(BorderFactory. layoutConstraints.layoutConstraints).gridx ridy = 0.fill H.

} } /* *Class Image_Panel */ private class Image_Panel extends JPanel { /* *Constructor for displaying an image to be decoded */ public Image_Panel() { //setup GridBagLayout GridBagLayout layout = new GridBagLayout().TER.B LACK.fill H.weightx .weighty = 50. decodeButton = new JButton("Decode Now").insets .JScrol lPane.gridwidth = 1.0).lightGray).0.gridx ridy = 0. = GridBagConstraints.gridh eight = 1.createLineBorder(Color.CEN = GridBagConstraints.anchor = GridBagConstraints. layoutConstraints.1)) . JScrollPane. image_input. add(scroll2). layoutConstraints.layoutConstraints).fill H.0.0.0. //set basic display setBackground(Color.setHorizontalAlignment(JLabel.CENTER).weightx . layoutConstraints = new Insets(0. layoutConstraints.setConstraints(encodeButton. layoutConstraints. layoutConstraints.HORIZONTAL_SCROLLBAR_AS_NEEDED).-5. layoutConstraints.setBorder(BorderFactory.setConstraints(scroll2.0. layoutConstraints. layoutConstraints.1)). scroll2. layoutConstraints .CEN = new Insets(0.0. layout.gridwidth = 1.createLineBorder(Color. layoutConstraints. setBorder(BorderFactory.weighty = 1. setLayout(layout). image_input = new JLabel(). layoutConstraints.anchor TER.g = 1. JScrollPane scroll2 = new JScrollPane(image_input. layout.-5. GridBagConstraints layoutConstraints = new GridBagConstr aints().VERTICAL_SCROLLBAR_AS_NEEDED.-5) = GridBagConstraints. layoutConstraints.layoutConstraints).BLACK.BOT = 0. add(encodeButton). layoutConstraints. layoutConstraints. layoutConstraints.gridh eight = 1.gridx = 0.gridy = 1 . layoutConstraints.BOT = 1.insets layoutConstraints.

createLineBorder(Color.BLACK. } } /* *Main Method for testing */ public static void main(String args[]) { new Steganography_View("Steganography").TER.1)) . setBorder(BorderFactory.layoutConstraints).setConstraints(decodeButton. //set basic display setBackground(Color.weightx .weighty = 1.lightGray). } } = 1.0. add(decodeButton). layout.0. layoutConstraints. layoutConstraints .