SlideShare a Scribd company logo
import java.awt.Color;
import java.awt.Insets;
import java.awt.Container;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JMenu;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.BorderFactory;
/*
*Class Steganography_View
*/
public class Steganography_View extends JFrame
{
//size variables for window
private static int WIDTH = 500;
private static int HEIGHT = 400;
//elements for JPanel
private JTextArea input;
private JScrollBar scroll,scroll2;
private JButton encodeButton,decodeButton;
private JLabel image_input;
//elements for Menu
private JMenu file;
private JMenuItem encode;
private JMenuItem decode;
private JMenuItem 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();
JMenu file = new JMenu("File"); file.setMnemonic('F');
encode = new JMenuItem("Encode"); encode.setMnemonic('E');
file.add(encode);
decode = new JMenuItem("Decode"); decode.setMnemonic('D');
file.add(decode);
file.addSeparator();
exit = new JMenuItem("Exit"); exit.setMnemonic('x'); file.add(exit);
menu.add(file);
setJMenuBar(menu);
// display rules
setResizable(true);//allow window to be resized: true?false
setBackground(Color.lightGray); /background color of window:
Color(int,int,int) setLocation(100,100); //location on the screen to display
window
setDefaultCloseOperation(EXIT_ON_CLOSE);//what to do on close operation: exit,
do_nothing, etc
setSize(WIDTH,HEIGHT); //set the size of the window
setVisible(true); //show the window: true?false
}
/*
*@return The menu item 'Encode'
*/
public JMenuItem getEncode() { return encode;
}
/*
*@return The menu item 'Decode'
*/
public JMenuItem getDecode() { return decode;
}
/*
*@return The menu item 'Exit'
*/
public JMenuItem getExit() { return
exit; }
/*
*@return The TextArea containing the text to encode
*/
public JTextArea getText() { return
input; }
/*
*@return The JLabel containing the image to decode text from
*/
public JLabel getImageInput() { return image_input;
}
/*
*@return The JPanel displaying the Encode View
*/
public JPanel getTextPanel() { return new Text_Panel(); }
/*
*@return The JPanel displaying the Decode View
*/
public JPanel getImagePanel() { return new Image_Panel(); }
/*
*@return The Encode button
*/
public JButton getEButton() { return encodeButton; }
/*
*@return The Decode button
*/
public JButton getDButton() { return decodeButton; }
/*
*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();
GridBagConstraints layoutConstraints = new
GridBagConstraints();
setLayout(layout);
input = new JTextArea();
layoutConstraints.gridx = 0; layoutConstraints.gridy =
0;
layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1;
layoutConstraints.fill = GridBagConstraints.BOTH;
layoutConstraints.insets = new Insets(0,0,0,0);
layoutConstraints.anchor = GridBagConstraints.CENTER;
layoutConstraints.weightx = 1.0; layoutConstraints.weighty
= 50.0;
JScrollPane scroll = new
JScrollPane(input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
layout.setConstraints(scroll,layoutConstraints);
scroll.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
add(scroll);
encodeButton = new JButton("Encode Now");
layoutConstraints.gridx = 0; layoutConstraints.gridy = 1;
layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1;
layoutConstraints.fill = GridBagConstraints.BOTH;
layoutConstraints.insets = new Insets(0,-5,-5,-5);
layoutConstraints.anchor = GridBagConstraints.CENTER;
layoutConstraints.weightx = 1.0; layoutConstraints.weighty
= 1.0;
layout.setConstraints(encodeButton,layoutConstraints);
add(encodeButton);
//set basic display
setBackground(Color.lightGray);
setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
}
}
/*
*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();
GridBagConstraints layoutConstraints = new
GridBagConstraints();
setLayout(layout);
image_input = new JLabel();
layoutConstraints.gridx = 0; layoutConstraints.gridy =
0;
layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1;
layoutConstraints.fill = GridBagConstraints.BOTH;
layoutConstraints.insets = new Insets(0,0,0,0);
layoutConstraints.anchor = GridBagConstraints.CENTER;
layoutConstraints.weightx = 1.0; layoutConstraints.weighty
= 50.0;
JScrollPane scroll2 = new
JScrollPane(image_input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
layout.setConstraints(scroll2,layoutConstraints);
scroll2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
image_input.setHorizontalAlignment(JLabel.CENTER);
add(scroll2);
decodeButton = new JButton("Decode Now");
layoutConstraints.gridx = 0; layoutConstraints.gridy = 1;
layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1;
layoutConstraints.fill = GridBagConstraints.BOTH;
layoutConstraints.insets = new Insets(0,-5,-5,-5);
layoutConstraints.anchor = GridBagConstraints.CENTER;
layoutConstraints.weightx = 1.0; layoutConstraints.weighty
= 1.0;
layout.setConstraints(decodeButton,layoutConstraints);
add(decodeButton);
//set basic display
setBackground(Color.lightGray);
setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
}
}
/*
*Main Method for testing
*/
public static void main(String args[])
{
new Steganography_View("Steganography");
}
}
Solution
import java.awt.Color;
import java.awt.Insets;
import java.awt.Container;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import javax.swing.JMenu;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JButton;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.BorderFactory;
/*
*Class Steganography_View
*/
public class Steganography_View extends JFrame
{
//size variables for window
private static int WIDTH = 500;
private static int HEIGHT = 400;
//elements for JPanel
private JTextArea input;
private JScrollBar scroll,scroll2;
private JButton encodeButton,decodeButton;
private JLabel image_input;
//elements for Menu
private JMenu file;
private JMenuItem encode;
private JMenuItem decode;
private JMenuItem 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();
JMenu file = new JMenu("File"); file.setMnemonic('F');
encode = new JMenuItem("Encode"); encode.setMnemonic('E');
file.add(encode);
decode = new JMenuItem("Decode"); decode.setMnemonic('D');
file.add(decode);
file.addSeparator();
exit = new JMenuItem("Exit"); exit.setMnemonic('x'); file.add(exit);
menu.add(file);
setJMenuBar(menu);
// display rules
setResizable(true);//allow window to be resized: true?false
setBackground(Color.lightGray); /background color of window:
Color(int,int,int) setLocation(100,100); //location on the screen to display
window
setDefaultCloseOperation(EXIT_ON_CLOSE);//what to do on close operation: exit,
do_nothing, etc
setSize(WIDTH,HEIGHT); //set the size of the window
setVisible(true); //show the window: true?false
}
/*
*@return The menu item 'Encode'
*/
public JMenuItem getEncode() { return encode;
}
/*
*@return The menu item 'Decode'
*/
public JMenuItem getDecode() { return decode;
}
/*
*@return The menu item 'Exit'
*/
public JMenuItem getExit() { return
exit; }
/*
*@return The TextArea containing the text to encode
*/
public JTextArea getText() { return
input; }
/*
*@return The JLabel containing the image to decode text from
*/
public JLabel getImageInput() { return image_input;
}
/*
*@return The JPanel displaying the Encode View
*/
public JPanel getTextPanel() { return new Text_Panel(); }
/*
*@return The JPanel displaying the Decode View
*/
public JPanel getImagePanel() { return new Image_Panel(); }
/*
*@return The Encode button
*/
public JButton getEButton() { return encodeButton; }
/*
*@return The Decode button
*/
public JButton getDButton() { return decodeButton; }
/*
*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();
GridBagConstraints layoutConstraints = new
GridBagConstraints();
setLayout(layout);
input = new JTextArea();
layoutConstraints.gridx = 0; layoutConstraints.gridy =
0;
layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1;
layoutConstraints.fill = GridBagConstraints.BOTH;
layoutConstraints.insets = new Insets(0,0,0,0);
layoutConstraints.anchor = GridBagConstraints.CENTER;
layoutConstraints.weightx = 1.0; layoutConstraints.weighty
= 50.0;
JScrollPane scroll = new
JScrollPane(input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
layout.setConstraints(scroll,layoutConstraints);
scroll.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
add(scroll);
encodeButton = new JButton("Encode Now");
layoutConstraints.gridx = 0; layoutConstraints.gridy = 1;
layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1;
layoutConstraints.fill = GridBagConstraints.BOTH;
layoutConstraints.insets = new Insets(0,-5,-5,-5);
layoutConstraints.anchor = GridBagConstraints.CENTER;
layoutConstraints.weightx = 1.0; layoutConstraints.weighty
= 1.0;
layout.setConstraints(encodeButton,layoutConstraints);
add(encodeButton);
//set basic display
setBackground(Color.lightGray);
setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
}
}
/*
*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();
GridBagConstraints layoutConstraints = new
GridBagConstraints();
setLayout(layout);
image_input = new JLabel();
layoutConstraints.gridx = 0; layoutConstraints.gridy =
0;
layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1;
layoutConstraints.fill = GridBagConstraints.BOTH;
layoutConstraints.insets = new Insets(0,0,0,0);
layoutConstraints.anchor = GridBagConstraints.CENTER;
layoutConstraints.weightx = 1.0; layoutConstraints.weighty
= 50.0;
JScrollPane scroll2 = new
JScrollPane(image_input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
layout.setConstraints(scroll2,layoutConstraints);
scroll2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
image_input.setHorizontalAlignment(JLabel.CENTER);
add(scroll2);
decodeButton = new JButton("Decode Now");
layoutConstraints.gridx = 0; layoutConstraints.gridy = 1;
layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1;
layoutConstraints.fill = GridBagConstraints.BOTH;
layoutConstraints.insets = new Insets(0,-5,-5,-5);
layoutConstraints.anchor = GridBagConstraints.CENTER;
layoutConstraints.weightx = 1.0; layoutConstraints.weighty
= 1.0;
layout.setConstraints(decodeButton,layoutConstraints);
add(decodeButton);
//set basic display
setBackground(Color.lightGray);
setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
}
}
/*
*Main Method for testing
*/
public static void main(String args[])
{
new Steganography_View("Steganography");
}
}

More Related Content

Similar to import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf (8)

PDF
PLEASE HELP ME !!IT IS Due Tonight ;(!i have to submit it before.pdf
mohammedfootwear
 
PDF
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
fastechsrv
 
PDF
This program create a Java Frame with 5 rows of button with capti.pdf
annamalaicells
 
DOCX
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
AliHaiderCheema2
 
PPT
Swing
Bharat17485
 
PDF
Java Program Photo Viewer1. Write an app called viewer that will .pdf
bhim1213
 
PDF
import java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdf
anupambedcovers
 
TXT
Interfaz Grafica En Java
Řỉgö VẻGầ
 
PLEASE HELP ME !!IT IS Due Tonight ;(!i have to submit it before.pdf
mohammedfootwear
 
Need help coding MorseCode in JavaCreate Class MorseCodeClient. T.pdf
fastechsrv
 
This program create a Java Frame with 5 rows of button with capti.pdf
annamalaicells
 
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
AliHaiderCheema2
 
Java Program Photo Viewer1. Write an app called viewer that will .pdf
bhim1213
 
import java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdf
anupambedcovers
 
Interfaz Grafica En Java
Řỉgö VẻGầ
 

More from venkt12345 (20)

PDF
To insert value X into a B-tree, there are 3 stepsIf there are M .pdf
venkt12345
 
PDF
The physical protection of knowledge, assets and personnel is key to.pdf
venkt12345
 
PDF
The function has 11 zeros , since the degree of function is 11So.pdf
venkt12345
 
PDF
Purpose of cashflow statements are to analyse the different cashflow.pdf
venkt12345
 
PDF
O,S as they belong to same groupSolutionO,S as they belong to .pdf
venkt12345
 
PDF
Modern Times is one of the greatest movies in the history of film. T.pdf
venkt12345
 
PDF
Main components of a computerMultimedia devicesOther peripheral .pdf
venkt12345
 
PDF
INTRODUCTION TO COAL MINING INDUSTRYEconomic growth world over is .pdf
venkt12345
 
PDF
Include time header file#includetime.hWrite main method like t.pdf
venkt12345
 
PDF
Identify the computer fraud and abuse technique byThis computer f.pdf
venkt12345
 
PDF
Given A fund that starts with a zero balance with time zero. Fund .pdf
venkt12345
 
PDF
Average.javaimport java.util.Scanner;public class Average{ .pdf
venkt12345
 
PDF
Your equation is correct. Double replacement reac.pdf
venkt12345
 
PDF
well while idenitfying aldehydeketone u must kee.pdf
venkt12345
 
PDF
The short answer is no. The reason why you cant p.pdf
venkt12345
 
PDF
Since it gets in equilibrium when dissolved at sa.pdf
venkt12345
 
PDF
phosphite ion .pdf
venkt12345
 
PDF
First, lets start with naming binary ionic comp.pdf
venkt12345
 
PDF
dFdy=dFdu dudy +dFdv dvdy =e^(u+v) 0 +e.pdf
venkt12345
 
PDF
At STP22.4 L Is Equivalent to 1 moleThereforeNo. of Moles = 31.pdf
venkt12345
 
To insert value X into a B-tree, there are 3 stepsIf there are M .pdf
venkt12345
 
The physical protection of knowledge, assets and personnel is key to.pdf
venkt12345
 
The function has 11 zeros , since the degree of function is 11So.pdf
venkt12345
 
Purpose of cashflow statements are to analyse the different cashflow.pdf
venkt12345
 
O,S as they belong to same groupSolutionO,S as they belong to .pdf
venkt12345
 
Modern Times is one of the greatest movies in the history of film. T.pdf
venkt12345
 
Main components of a computerMultimedia devicesOther peripheral .pdf
venkt12345
 
INTRODUCTION TO COAL MINING INDUSTRYEconomic growth world over is .pdf
venkt12345
 
Include time header file#includetime.hWrite main method like t.pdf
venkt12345
 
Identify the computer fraud and abuse technique byThis computer f.pdf
venkt12345
 
Given A fund that starts with a zero balance with time zero. Fund .pdf
venkt12345
 
Average.javaimport java.util.Scanner;public class Average{ .pdf
venkt12345
 
Your equation is correct. Double replacement reac.pdf
venkt12345
 
well while idenitfying aldehydeketone u must kee.pdf
venkt12345
 
The short answer is no. The reason why you cant p.pdf
venkt12345
 
Since it gets in equilibrium when dissolved at sa.pdf
venkt12345
 
phosphite ion .pdf
venkt12345
 
First, lets start with naming binary ionic comp.pdf
venkt12345
 
dFdy=dFdu dudy +dFdv dvdy =e^(u+v) 0 +e.pdf
venkt12345
 
At STP22.4 L Is Equivalent to 1 moleThereforeNo. of Moles = 31.pdf
venkt12345
 
Ad

Recently uploaded (20)

PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
grade 5 lesson ENGLISH 5_Q1_PPT_WEEK3.pptx
SireQuinn
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
community health nursing question paper 2.pdf
Prince kumar
 
Ad

import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf

  • 1. import java.awt.Color; import java.awt.Insets; import java.awt.Container; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import javax.swing.JMenu; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JTextArea; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.BorderFactory; /* *Class Steganography_View */ public class Steganography_View extends JFrame { //size variables for window private static int WIDTH = 500; private static int HEIGHT = 400; //elements for JPanel private JTextArea input; private JScrollBar scroll,scroll2; private JButton encodeButton,decodeButton; private JLabel image_input; //elements for Menu private JMenu file; private JMenuItem encode; private JMenuItem decode; private JMenuItem exit;
  • 2. /* *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(); JMenu file = new JMenu("File"); file.setMnemonic('F'); encode = new JMenuItem("Encode"); encode.setMnemonic('E'); file.add(encode); decode = new JMenuItem("Decode"); decode.setMnemonic('D'); file.add(decode); file.addSeparator(); exit = new JMenuItem("Exit"); exit.setMnemonic('x'); file.add(exit); menu.add(file); setJMenuBar(menu); // display rules setResizable(true);//allow window to be resized: true?false setBackground(Color.lightGray); /background color of window: Color(int,int,int) setLocation(100,100); //location on the screen to display window setDefaultCloseOperation(EXIT_ON_CLOSE);//what to do on close operation: exit, do_nothing, etc setSize(WIDTH,HEIGHT); //set the size of the window setVisible(true); //show the window: true?false } /* *@return The menu item 'Encode' */ public JMenuItem getEncode() { return encode; } /* *@return The menu item 'Decode'
  • 3. */ public JMenuItem getDecode() { return decode; } /* *@return The menu item 'Exit' */ public JMenuItem getExit() { return exit; } /* *@return The TextArea containing the text to encode */ public JTextArea getText() { return input; } /* *@return The JLabel containing the image to decode text from */ public JLabel getImageInput() { return image_input; } /* *@return The JPanel displaying the Encode View */ public JPanel getTextPanel() { return new Text_Panel(); } /* *@return The JPanel displaying the Decode View */ public JPanel getImagePanel() { return new Image_Panel(); } /* *@return The Encode button */ public JButton getEButton() { return encodeButton; } /* *@return The Decode button */ public JButton getDButton() { return decodeButton; } /* *Class Text_Panel
  • 4. */ private class Text_Panel extends JPanel { /* *Constructor to enter text to be encoded */ public Text_Panel() { //setup GridBagLayout GridBagLayout layout = new GridBagLayout(); GridBagConstraints layoutConstraints = new GridBagConstraints(); setLayout(layout); input = new JTextArea(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,0,0,0); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 50.0; JScrollPane scroll = new JScrollPane(input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); layout.setConstraints(scroll,layoutConstraints); scroll.setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); add(scroll); encodeButton = new JButton("Encode Now"); layoutConstraints.gridx = 0; layoutConstraints.gridy = 1; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,-5,-5,-5); layoutConstraints.anchor = GridBagConstraints.CENTER;
  • 5. layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 1.0; layout.setConstraints(encodeButton,layoutConstraints); add(encodeButton); //set basic display setBackground(Color.lightGray); setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); } } /* *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(); GridBagConstraints layoutConstraints = new GridBagConstraints(); setLayout(layout); image_input = new JLabel(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,0,0,0); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 50.0; JScrollPane scroll2 = new JScrollPane(image_input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
  • 6. JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); layout.setConstraints(scroll2,layoutConstraints); scroll2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); image_input.setHorizontalAlignment(JLabel.CENTER); add(scroll2); decodeButton = new JButton("Decode Now"); layoutConstraints.gridx = 0; layoutConstraints.gridy = 1; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,-5,-5,-5); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 1.0; layout.setConstraints(decodeButton,layoutConstraints); add(decodeButton); //set basic display setBackground(Color.lightGray); setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); } } /* *Main Method for testing */ public static void main(String args[]) { new Steganography_View("Steganography"); } } Solution import java.awt.Color;
  • 7. import java.awt.Insets; import java.awt.Container; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import javax.swing.JMenu; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JTextArea; import javax.swing.JScrollBar; import javax.swing.JScrollPane; import javax.swing.BorderFactory; /* *Class Steganography_View */ public class Steganography_View extends JFrame { //size variables for window private static int WIDTH = 500; private static int HEIGHT = 400; //elements for JPanel private JTextArea input; private JScrollBar scroll,scroll2; private JButton encodeButton,decodeButton; private JLabel image_input; //elements for Menu private JMenu file; private JMenuItem encode; private JMenuItem decode; private JMenuItem exit; /* *Constructor for Steganography_View class
  • 8. *@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(); JMenu file = new JMenu("File"); file.setMnemonic('F'); encode = new JMenuItem("Encode"); encode.setMnemonic('E'); file.add(encode); decode = new JMenuItem("Decode"); decode.setMnemonic('D'); file.add(decode); file.addSeparator(); exit = new JMenuItem("Exit"); exit.setMnemonic('x'); file.add(exit); menu.add(file); setJMenuBar(menu); // display rules setResizable(true);//allow window to be resized: true?false setBackground(Color.lightGray); /background color of window: Color(int,int,int) setLocation(100,100); //location on the screen to display window setDefaultCloseOperation(EXIT_ON_CLOSE);//what to do on close operation: exit, do_nothing, etc setSize(WIDTH,HEIGHT); //set the size of the window setVisible(true); //show the window: true?false } /* *@return The menu item 'Encode' */ public JMenuItem getEncode() { return encode; } /* *@return The menu item 'Decode' */ public JMenuItem getDecode() { return decode;
  • 9. } /* *@return The menu item 'Exit' */ public JMenuItem getExit() { return exit; } /* *@return The TextArea containing the text to encode */ public JTextArea getText() { return input; } /* *@return The JLabel containing the image to decode text from */ public JLabel getImageInput() { return image_input; } /* *@return The JPanel displaying the Encode View */ public JPanel getTextPanel() { return new Text_Panel(); } /* *@return The JPanel displaying the Decode View */ public JPanel getImagePanel() { return new Image_Panel(); } /* *@return The Encode button */ public JButton getEButton() { return encodeButton; } /* *@return The Decode button */ public JButton getDButton() { return decodeButton; } /* *Class Text_Panel */ private class Text_Panel extends JPanel
  • 10. { /* *Constructor to enter text to be encoded */ public Text_Panel() { //setup GridBagLayout GridBagLayout layout = new GridBagLayout(); GridBagConstraints layoutConstraints = new GridBagConstraints(); setLayout(layout); input = new JTextArea(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,0,0,0); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 50.0; JScrollPane scroll = new JScrollPane(input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); layout.setConstraints(scroll,layoutConstraints); scroll.setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); add(scroll); encodeButton = new JButton("Encode Now"); layoutConstraints.gridx = 0; layoutConstraints.gridy = 1; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,-5,-5,-5); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 1.0;
  • 11. layout.setConstraints(encodeButton,layoutConstraints); add(encodeButton); //set basic display setBackground(Color.lightGray); setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); } } /* *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(); GridBagConstraints layoutConstraints = new GridBagConstraints(); setLayout(layout); image_input = new JLabel(); layoutConstraints.gridx = 0; layoutConstraints.gridy = 0; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,0,0,0); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 50.0; JScrollPane scroll2 = new JScrollPane(image_input,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); layout.setConstraints(scroll2,layoutConstraints);
  • 12. scroll2.setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); image_input.setHorizontalAlignment(JLabel.CENTER); add(scroll2); decodeButton = new JButton("Decode Now"); layoutConstraints.gridx = 0; layoutConstraints.gridy = 1; layoutConstraints.gridwidth = 1; layoutConstraints.gridheight = 1; layoutConstraints.fill = GridBagConstraints.BOTH; layoutConstraints.insets = new Insets(0,-5,-5,-5); layoutConstraints.anchor = GridBagConstraints.CENTER; layoutConstraints.weightx = 1.0; layoutConstraints.weighty = 1.0; layout.setConstraints(decodeButton,layoutConstraints); add(decodeButton); //set basic display setBackground(Color.lightGray); setBorder(BorderFactory.createLineBorder(Color.BLACK,1)); } } /* *Main Method for testing */ public static void main(String args[]) { new Steganography_View("Steganography"); } }