-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSteganography_View.java
More file actions
249 lines (230 loc) · 6.58 KB
/
Steganography_View.java
File metadata and controls
249 lines (230 loc) · 6.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
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 JMenu
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);
// JMenubar
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
// allow window to be resized: true?false
setResizable(true);
// background color of window: Color(int,int,int) or Color.name
setBackground(Color.lightGray);
// set first location on the screen to display window
setLocation(100,100);
// what to do on close operation: exit, do_nothing, etc
setDefaultCloseOperation(EXIT_ON_CLOSE);
// set the size of the window
setSize(WIDTH,HEIGHT);
// show the window: true?false
setVisible(true);
}
/*
*@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();
// set constraints for text panel
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");
// set constraints for decode button
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();
// set constraints for image panel
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");
// set constraints for decode button
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");
}
}