[Solved]Sample Exam Questions Part 4 S Another Gui Question Asked Provide One Given Following Code Q37017982

Sample Exam Questions Part 4 Here’s another GUI question as I was asked to provide one You are given the following code for the Model and View of a system that has a text field in the GUI. The String can be changed in the Model and when that happens, the View must update the corresponding text field in the JPanel (which will go in the GUI). The Controller is not shown as you don’t need to modify it. public class View extends JPanel private JTextField ourString; public View) ourString – new JTextField ); ourString.setEditable (false); ourString.setHorizontalAlignment (JTextField.RIGHT); setLayout (new GridLayout (1,1)); add (ourString); public class Model private String theString; public Model ) theString=””; public void setString (String s) tf theString-s; public String getString)[ return theString; Change the code above so that the Observer pattern is used to have the code function as describec You will find the APl needed in the reference material for the second set of sample questions. You may assume that the Controller class (not shown) correctly sets up the Observer pattern for the two classes above JTextField methods that you might find useful include public void setText(String t);//puts String t in the JTextField public String getText():/returns the String currently in the JTextField addActionListener(ActionListener l);// adds the ActionListener to get action events from the JTextField Show transcribed image text Sample Exam Questions Part 4 Here’s another GUI question as I was asked to provide one You are given the following code for the Model and View of a system that has a text field in the GUI. The String can be changed in the Model and when that happens, the View must update the corresponding text field in the JPanel (which will go in the GUI). The Controller is not shown as you don’t need to modify it. public class View extends JPanel private JTextField ourString; public View) ourString – new JTextField ); ourString.setEditable (false); ourString.setHorizontalAlignment (JTextField.RIGHT); setLayout (new GridLayout (1,1)); add (ourString); public class Model private String theString; public Model ) theString=””; public void setString (String s) tf theString-s; public String getString)[ return theString; Change the code above so that the Observer pattern is used to have the code function as describec You will find the APl needed in the reference material for the second set of sample questions. You may assume that the Controller class (not shown) correctly sets up the Observer pattern for the two classes above JTextField methods that you might find useful include public void setText(String t);//puts String t in the JTextField public String getText():/returns the String currently in the JTextField addActionListener(ActionListener l);// adds the ActionListener to get action events from the JTextField
Expert Answer
Answer to Sample Exam Questions Part 4 Here’s another GUI question as I was asked to provide one You are given the following code … . . .
OR

