Consolidation. Code making (i.e. making ciphers) is undertaken by a cryptographer whereas cryptanalysts try to break ciphers in order to gain intelligence.

Slides:



Advertisements
Similar presentations
Graphical User Interfaces
Advertisements

Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
Java Swing Recitation – 11/(20,21)/2008 CS 180 Department of Computer Science, Purdue University.
Event Driven Programming and GUIs Part 3 CS221 – 4/15/09.
GUI Tutorial Day 3. Custom Dialog Create, display, hide, retrieve information.
Event-Driven Programming Thus far, our programs have been executed one statement after the other However, many programs depend on user actions to dictate.
Java GUI Libraries Swing Programming. Swing Components Swing is a collection of libraries that contains primitive widgets or controls used for designing.
IEEM 110 Computing in Industrial Applications Basic User Interface in Java.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
GUI and Event-Driven Programming Recitation – 3/6/2009 CS 180 Department of Computer Science, Purdue University.
Chapter 121 Window Interfaces Using Swing Chapter 12.
1 Class 8. 2 Chapter Objectives Use Swing components to build the GUI for a Swing program Implement an ActionListener to handle events Add interface components.
Lesson 35: Review of the Java GUI. The JFrame, Container and JButton.
Chapter 8: Graphical User Interfaces Objectives - by the end of this chapter, you should be able to do the following: –write a simple graphical user interface.
Introduction to GUI Java offers a great number of pre-defined classes to support the development of graphical user interfaces –These are broken down into.
Combo Box, Check Boxes, and Radio Buttons. Radio Buttons User can click radio buttons, just like other buttons BUT Radio buttons are mutually exclusive.
1 Event Driven Programming wirh Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
F27SB2 Software Development 2 Lecture 6: Java GUIs 5.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
עקרונות תכנות מונחה עצמים תרגול 4 - GUI. Outline  Introduction to GUI  Swing  Basic components  Event handling.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
GUI Components and Design Here we add one more component to our programs, JButtons –JButtons can only be inserted into JPanels (or JApplets) –Clicking.
CS Lecture 01 Frames and Components and events Lynda Thomas
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Object-Oriented Programming (Java), Unit 18 Kirk Scott 1.
Swing GUI Components You can create graphics components to place on your applet using classes available in the Swing package ( javax.swing ) Class names.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Layout Managers Arranges and lays out the GUI components on a container.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
GUI Basics. What is GUI? A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs in more ways than.
1 Class 6. 2 Objectives Objectives Enable your applications to perform actions in response to JButton clicks Get the text the user enters in a textfield.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Introduction to GUI in 1 Graphical User Interface 2 Nouf Almunyif.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7-2 ( Book Chapter 14) GUI and Event-Driven Programming.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Review_6 AWT, Swing, ActionListener, and Graphics.
Graphical User Interfaces A Graphical User Interface (GUI) in Java is created with at least three kinds of objects: –components, events, and listeners.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 4 – Completing the Inventory Application.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
1 Event Driven Programs with a Graphical User Interface Rick Mercer.
GUI Tutorial 1. A Bit of Philosophy on what to Teach  There are numerous libraries, frameworks, options  Modern GUIs are often developed using XML (e.g.,
Event-Driven Programming F Procedural programming is executed in procedural order. F In event-driven programming, code is executed upon activation of events.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 17.1 Test-Driving the Student Grades Application.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Swing GUI Components So far, we have written GUI applications which can ‘ draw ’. These applications are simple, yet typical of all Java GUI applications.
Lesson 28: More on the GUI button, frame and actions.
Graphical User Interface (GUI)
MIT AITI 2004 Swing Event Model Lecture 17. The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
Dept. of CSIE, National University of Tainan 10/21/2012 Responding to User Input.
Java Visual Applications CSIS 3701: Advanced Object Oriented Programming.
GUI Programming in Java Hao Jiang Boston College April, 2009.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7 ( Book Chapter 14) GUI and Event-Driven Programming.
A Quick Java Swing Tutorial
Multiple buttons and action calls
Modular Event Handling
GUIs and Events Rick Mercer.
Introduction Many Java application use a graphical user interface or GUI (pronounced “gooey”). A GUI is a graphical window or windows that provide interaction.
A First Look at GUI Applications
CHAPTER 7 & 8 REVIEW QUESTIONS
Ellen Walker Hiram College
MVC Paradigm The MVC paradigm breaks applications or interfaces into three parts: the model, the view, and the controller. A --> 25 % B --> 60 % C -->
Advanced Programming in Java
Constructors, GUI’s(Using Swing) and ActionListner
Graphical User Interface
Presentation transcript:

Consolidation

Code making (i.e. making ciphers) is undertaken by a cryptographer whereas cryptanalysts try to break ciphers in order to gain intelligence about enemy activity. The diagram below illustrates the process of encoding and decoding text.

A well-known kind of substitution encryption is the Caesar Cipher Shift. Julius Caesar used this algorithm to encrypt messages sent to officials. In this algorithm each plain text character is replaced by a character N places after (or before) that character. Here the key contains a shift number. So if the key had the value 1 then the text Hello world Would be encrypted as: IFMMN XNSME You are required to develop a game program that supports the Caesar cipher shift algorithm. The game is undertaken by two players using a single Java application running on one computer: the cryptographer and the cryptanalyst.

The cryptographer is presented with a window (JFrame) that allows her to enter a plain text message (of about 10 lines, with only alphabetic characters and space punctuation). She can also select a key using a JComboBox that allows a shift of between 1 and 25. Shift left and shift right JRadioButtons should be used to indicate the direction of substitution. A separate read-only text area displays the resulting cipher text. The cryptanalyst’s window is then displayed, just showing the read-only cipher text. The cryptanalyst is then required to decrypt the cipher and typing the decrypted plain text in a separate text area input field. When satisfied with the decryption she hits the “Decrypted” button. The program must compare the decrypted text with the original plain text and provide a score showing the percentage of characters that were entered in the correct position.

Design the screens

You got 60% The answer was hello Type words here How many places Will look like this encrypt done What happens when close? hello ifmmp 1 You see Type guess here guess What happens when close? ifmmp henno quit

What objects does that lead to? Cryptographer? Cryptoanalyst? Something in background holding the model (what is in the model?)

Starting with SimpleImproved code public class MyDriver{ public static void main(String a[]){ MyFrame app=new MyFrame(); } Need 2 frames 1 for cryptographer 1 for cryptoanalyst Also create the model Pass the model to the frames AND ???

roughly public class MyDriver{ public static void main(String args[]) { Model m=new Model(); Cryptanalyst p2=new Cryptanalyst(m); Cryptographer p1=new Cryptographer(m,p2); }

import javax.swing.*; public class MyFrame extends JFrame{ private MyPanel panel; public MyFrame() { panel= new MyPanel(); add(panel); setSize(200,200); setLocation(200,200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("demo swing"); setVisible(true); } Could base both on this Note could have a different default close operation for the 1 st person (instead perhaps it should just close that frame) Or possibly for both

roughly import javax.swing.*; public class Cryptographer extends JFrame{ private CryptoPanel panel; public Cryptographer(Model m, Cryptanalyst p) { panel= new CryptoPanel(m, p, this); add(panel); setSize(200,200); setLocation(200,200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //probably not! setTitle("cryptographer"); setVisible(true); }

roughly import javax.swing.*; public class Cryptanalyst extends JFrame{ private AnalystPanel panel; public Cryptanalyst (Model m) { panel= new AnalystPanel(m); add(panel); setSize(200,200); setLocation(300,300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //maybe? setTitle("CRYPTANALYST"); setVisible(false); }

import javax.swing.*; import java.awt.event.*; public class MyPanel extends JPanel implements ActionListener{ private JButton button; private String name; public MyPanel() { button=new JButton("Hello"); add(button); button.addActionListener(this); } public void actionPerformed(ActionEvent e){ System.out.println("pressed"); name = JOptionPane.showInputDialog (null,"Enter name : ","entry", 1); if(name != null) JOptionPane.showMessageDialog(null, "hallo : " + name,"entry", 1); }

The panel in the Cryptographer frame could be a GridLayout with 4 rows and 2 columns It needs 2 JButtons, 2 JTextFields and 4 JLabels (worry about the radio button later) When the encrypt button is pressed it takes what they typed and updates the model When the done button is pressed it makes its frame not visible and makes the OTHER frame visible Note this means you need a link back to this frame and a link to the other frame Type words here How many places Will look like this encrypt done What happens when close? hello ifmmp 1

roughly import javax.swing.*; import java.awt.event.*; public class CryptoPanel extends JPanel implements ActionListener{ private Model model; private Cryptanalyst otherPlayer; private Cryptographer parent; private JButton done; public CryptoPanel(Model m, Cryptanalyst c, Cryptographer p) { model=m; otherPlayer=c; parent=p; done=new JButton("done"); add(done); done.addActionListener(this); //also encrypt button } public void actionPerformed (ActionEvent e) { System.out.println("pressed player 1"); //when they press done make the otherPlayer visible and make this frame invisible otherPlayer.setVisible(true); parent.setVisible (false); //when they press encrypt update the model with the values }

The panel in the Cryptoanalyst frame could be a GridLayout with 3 rows and 2 columns It needs 2 JButtons, 1 JTextFields and 3 JLabels When the guess button is pressed it compares the value in the JTextField to the value in the model and pops up a show MessageDialog with the stats When the quit button is pressed it quits You got 60% The answer was hello You see Type guess here guess What happens when close? ifmmp henno quit

VERY roughly import javax.swing.*; import java.awt.event.*; public class AnalystPanel extends JPanel implements ActionListener{ private Model model; public AnalystPanel(Model m) { model=m; //buttons, make sure ‘this’ listens to buttons, and textfield } public void actionPerformed(ActionEvent e){ System.out.println("pressed player 2"); //when they press ‘guess’ call a method of model with the value in the JTextField //that should return a string (the % right and the answer) //display that using //JOptionPane.showMessageDialog(null, returnedString, 1); } }

I will make this available It is incomplete