This is a Java coding question. I've included the given source files(4 pictured at the bottom) that need to be modified according to the given instructions.
Edit: I don't understand the comment. but truly any tips or helpful hints, anyone can provide would be appreciated.
EDIT 2: All code added in text form under their respective photos.
INSTRUCTIONS:
GuiReflectApp.java
package org.t11;
import org.t11.model.Student; import org.t11.view.MainFrame;
public class GuiReflectApp { /** * Main entry point for this application * * @param args the command line arguments (ignored) */ public static void main(String[] args) { Student model = new Student(); model.setName("Student CS390Regis"); // Change this to using reflection. MainFrame frame = new MainFrame(); frame.setModel(model); } }
MainFrame.java
package org.t11.view;
import org.t11.model.Student; import javax.swing.JFrame; import javax.swing.WindowConstants;
public class MainFrame extends JFrame { // TODO private StudentView view; private Student model; public MainFrame() { super("Assignment Topic 11"); initializeComponents(); layoutComponents(); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setSize(400, 400); setVisible(true); } public Student getModel() { return model; }
public void setModel(Student model) { this.model = model; view.setModel(model); } private void initializeComponents() { // TODO load via reflection view = new StudentView(); } private void layoutComponents() { getContentPane().add(view); } }
StudentView.java
package org.t11.view;
import org.t11.model.Student; import javax.swing.JLabel;
public class StudentView extends JLabel { /** * The Student model displayed in this view. */ private Student model;
public Student getModel() { return model; }
/** * Display the given model in this view * * @param model to display in the Frame */ public void setModel(Student model) { this.model = model; updateDisplay(); } /** * Display the current model in this view. */ private void updateDisplay() { // TODO: Use reflection here. setText(model.getName()); } }
Student.java
package org.t11.model;
public class Student { private String name; public Student() { this.name = ""; }
public String getName() { return name; }
public void setName(String name) { this.name = name; } public String getViewClass() { return ""; // TODO } @Override public String toString() { return name; } }
Im sorry. I truly didnt mean to put anyone out.
Background: Consider the following UML design, creates GulReflectApp Mainframe javax.swing.JLabel model Student ModelStudent model vold Emaintindi Steinger) Student StudentView - mode: Student Modestudent medewold creates model name getNameString same/String navod ViewName: String This design is implemented in the NetBeans project given in this Topic's online Worldclass notes. When you run this NetBeans application, it displays a single window frame, which contains a view displaying the name of the associated student model. In this application, the creation of the Student Student view and its relation to the Student model is hard-coded within the application, Functional Requirements Part 1: 1. Change the design of this GuiReflectApp application to remove the hard coding of the StudentView and its knowledge of a StudentModel. Instead, use reflection to ask the passed Model object for its associated view using the model's getViewName() method, which should return the fully qualified class name of the view that is used to display this object (in this example, it will be the StudentView) Hence, you are not changing the overall logic or design of this program, but simply using the reflection to create the StudentView class that is added to the Mainframe. 2. Use reflection to replace the "getName()" and setName(...) messages sent to the Student model. (See the main() method and updateDisplay() method in Student View). 3. Appropriately handle all exceptions Essentially, you are replacing the hard-coded "new StudentView()" and "model.getName()" methods in the existing project. 1 package org.t11; 2 3 import org.t11.model. Student; 4 import org.t11.view.Mainframe; S 7 8 10 6 epublic class Gui ReflectApp /** * Main entry point for this application @param args the command line arguments (ignored) 11 12 public static void main(String[] args) { 13 Student model = new Student (); 14 model.setName ("Student CS 390 Regis"); // Change this to using reflection. 15 16 Mainframe frame = new Main Frame(): 17 18 frame.setModel (model); 19 20 21 8 1 package org.t11.view; 2 3 import org.t11.model. Student; 4 import javax.swing.JFrame: 5 import javax.swing.WindowConstants; 6 7 epublic class Mainframe extends JFrame // TODO 9 private StudentView view: 10 11 private Student model; 12 13 public Mainframe() { 14 super("Assignment Topic 11"); 15 16 initializeComponents(): 17 layout Components(): 18 19 this.setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE) ; 20 21 setSize (400, 400); 22 setVisible(true); 23 24 25 public Student gotModel() { 26 return model; 27 } 28 29 public void set Model (Student model) { 3D this.model = model; 31 32 view.setModel (model); 33 } 34 35 private void initializeComponents() { 36 // TODO load via reflection 37 view = new StudentView(): ) 39 10 private void layoutComponents() ( 41 getContent Pane () .add(view); 38 1 package org.t11.view; 2 3 import org.t11.model. Student; 4 import javax.swing.JLabel; 5 6 7 epublic class StudentView extends JLabel / 8 e /** 9 + The Student model displayed in this view. 10 +/ 11 private Student model; 12 13 public Student getModel() { 14 return model; 15 } 16 17 /** 18 + Display the given model in this view 19 20 @param model to display in the frame 21 22 public void setModel (Student model) { 23 this.model = model; 24 25 updateDisplay(); 26 27 28 29 * Display the current model in this view. 30 +7 31 private void updateDisplay() { 32 // TODO: . Use reflection here. 33 setText (model.getName()); 34 } 35 } 36 sy 1111 1 package org.t11.model; 2 3. Epublic class Student { 4 private String name; 5 public Student () { 7 this.name 8 } 9 10 e public String getName() { 11 return name; 12 } 13 14 public void setName (String name) { 15 this.name = name; 16 } 17 18 19 20 public String getViewClass() { return ""; // TODO } 21 @Override public String toString() { return name; 22 23 24 25 26 27 } } Background: Consider the following UML design, creates GulReflectApp Mainframe javax.swing.JLabel model Student ModelStudent model vold Emaintindi Steinger) Student StudentView - mode: Student Modestudent medewold creates model name getNameString same/String navod ViewName: String This design is implemented in the NetBeans project given in this Topic's online Worldclass notes. When you run this NetBeans application, it displays a single window frame, which contains a view displaying the name of the associated student model. In this application, the creation of the Student Student view and its relation to the Student model is hard-coded within the application, Functional Requirements Part 1: 1. Change the design of this GuiReflectApp application to remove the hard coding of the StudentView and its knowledge of a StudentModel. Instead, use reflection to ask the passed Model object for its associated view using the model's getViewName() method, which should return the fully qualified class name of the view that is used to display this object (in this example, it will be the StudentView) Hence, you are not changing the overall logic or design of this program, but simply using the reflection to create the StudentView class that is added to the Mainframe. 2. Use reflection to replace the "getName()" and setName(...) messages sent to the Student model. (See the main() method and updateDisplay() method in Student View). 3. Appropriately handle all exceptions Essentially, you are replacing the hard-coded "new StudentView()" and "model.getName()" methods in the existing project. 1 package org.t11; 2 3 import org.t11.model. Student; 4 import org.t11.view.Mainframe; S 7 8 10 6 epublic class Gui ReflectApp /** * Main entry point for this application @param args the command line arguments (ignored) 11 12 public static void main(String[] args) { 13 Student model = new Student (); 14 model.setName ("Student CS 390 Regis"); // Change this to using reflection. 15 16 Mainframe frame = new Main Frame(): 17 18 frame.setModel (model); 19 20 21 8 1 package org.t11.view; 2 3 import org.t11.model. Student; 4 import javax.swing.JFrame: 5 import javax.swing.WindowConstants; 6 7 epublic class Mainframe extends JFrame // TODO 9 private StudentView view: 10 11 private Student model; 12 13 public Mainframe() { 14 super("Assignment Topic 11"); 15 16 initializeComponents(): 17 layout Components(): 18 19 this.setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE) ; 20 21 setSize (400, 400); 22 setVisible(true); 23 24 25 public Student gotModel() { 26 return model; 27 } 28 29 public void set Model (Student model) { 3D this.model = model; 31 32 view.setModel (model); 33 } 34 35 private void initializeComponents() { 36 // TODO load via reflection 37 view = new StudentView(): ) 39 10 private void layoutComponents() ( 41 getContent Pane () .add(view); 38 1 package org.t11.view; 2 3 import org.t11.model. Student; 4 import javax.swing.JLabel; 5 6 7 epublic class StudentView extends JLabel / 8 e /** 9 + The Student model displayed in this view. 10 +/ 11 private Student model; 12 13 public Student getModel() { 14 return model; 15 } 16 17 /** 18 + Display the given model in this view 19 20 @param model to display in the frame 21 22 public void setModel (Student model) { 23 this.model = model; 24 25 updateDisplay(); 26 27 28 29 * Display the current model in this view. 30 +7 31 private void updateDisplay() { 32 // TODO: . Use reflection here. 33 setText (model.getName()); 34 } 35 } 36 sy 1111 1 package org.t11.model; 2 3. Epublic class Student { 4 private String name; 5 public Student () { 7 this.name 8 } 9 10 e public String getName() { 11 return name; 12 } 13 14 public void setName (String name) { 15 this.name = name; 16 } 17 18 19 20 public String getViewClass() { return ""; // TODO } 21 @Override public String toString() { return name; 22 23 24 25 26 27 } }