Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

import java.awt.*;import java.awt.event.*;import javax.swing.event.*;import java

ID: 3616731 • Letter: I

Question

 import java.awt.*;import java.awt.event.*;import javax.swing.event.*;import javax.swing.*;import javax.swing.text.*;public class CipherGUI {public static void main(String args[]) {try {UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());} catch (Exception e) {}JFrame cipherGUIFrame = new CipherGUIFrame();cipherGUIFrame.setVisible(true);}}class CipherGUIFrame extends JFrame {public CipherGUIFrame() {super("Caesar Cipher GUI");setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setSize(400, 600);Container content = getContentPane();content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));}}





Your GUI will have 4 main controls:
  1. A JTextArea for cleartextinput/output
  2. A JSpinner for key input
  3. A JToggleButton labeled 'Encrypt'for Encrypt/Decrypt
  4. A JTextArea for ciphertextinput/output
 
Modify the class CipherGUIFrame to have private member variables for these controls and a constructor that creates them and puts them in the content pane. The controls can be created with their default constructors. The JToggleButton can be constructed using the button constructor you are familiar with for labeling the button. The BoxLayout for the content pane will add components to the frame from top to bottom. You should add basic labels to identify the controls and also add a panel to contain the spinner and toggle button.
The JSpinner will have an event listener for the change event. Look up the interface ChangeListener in the Java documentation. Your observer should be added to your JSpinner and should simply print the line "Key Spinner Changed" to System.out when the event occurs.
The JToggleButton will have an event listener for the action event. You should be familiar with this event from our previous work. This event should cause the printing of the line "Encrypt Toggle Pressed" when the JToggleButton is pressed.
The two JTextArea controls will have slightly more complicated observers. We will attach listeners to these controls' Documents. We need to access the document by calling the getDocument() method. Attach a DocumentListener to the document using addDocumentListener(Document doc). Look up the interface DocumentListener and implement methods which print to System.out to indicate the event occurred. You will not need to implement changedUpdate as it is not fired for plaintext Documents.
When complete, you should have a window with a text area at the top, the spinner and toggle button in the middle, a text area at the bottom, and appropriate labels. Each of the four controls should print System.out message for their corresponding events.


Explanation / Answer

Dear...     Am giving you the sample code for first twooptions. Try for remaining. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class TextArea1 extends JApplet implementsActionListener { JTextField Input; JTextArea echo; JTextArea echo2; Container panel; LayoutManager Layout; public TextArea1 () {     input = new JTextField ("Input", 20);     input = new JTextField ("Input", 20);     echo = new JTextArea (5, 20);     echo2 = new JTextArea (5, 20);     layout = new FlowLayout ();     panel = getContentPane ();   input.addActionListener (this);     echo.setEditable (false);     echo.setBackground (Color.green);     echo.setLineWrap (true);     panel.setLayout (Layout);     panel.add (Input);     panel.add (Echo);     panel.add (Echo2);     panel.setBackground (Color.yellow); } public void actionPerformed (ActionEvent e)   {     string Reply;     reply = "The text which was entered intothe JTextField was "" + Input.getText()                                                                              + "", and this is the echo with text wrap.";     echo.setText (Reply);     reply = "The text which was entered intothe JTextField was "" + Input.getText()                                                                                    + "", and this is the echo with returns.";     echo2.setText (Reply); } } }
Method for JSpinner for key input


try    {       spinner.commitEdit();    }    catch (ParseException pe)     {        JComponent editor =spinner.getEditor()        if (editor instanceofDefaultEditor)          {           ((DefaultEditor)editor).getTextField().setValue(spinner.getValue();          }         spinner.setValue(fallbackValue);    }    return spinner.getValue();    return spinner.getValue();



Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote