Note that there are some explanatory texts on larger screens.

plurals
  1. POOverriding abstract methods in Java
    primarykey
    data
    text
    <p>Here is a class View of the MVC paradigm, the class consist of 2 <code>JDialogs</code>, to be opened on click of <code>JMenuItem</code> - <code>addEvent</code> and <code>editEvent</code>. </p> <pre><code> public class EventView extends javax.swing.JFrame { private javax.swing.JDialog addDialog; private javax.swing.JDialog editDialog; private EventModel model; /** Constructor */ public EventView(EventModel model) { initComponents(); this.model = model; updateEventTable(); } public void addEventListener(ActionListener al) { addEventButton.addActionListener(al); } /* public void clearListener(ActionListener cl) { clearEventButton.addActionListener(cl); }*/ public void addDialog(ActionListener ae) { addEvent.addActionListener(ae); } public void editDialog(ActionListener ee) { editEvent.addActionListener(ee); } } </code></pre> <p>The controller class handles the user interaction with listeners. </p> <pre><code>public class EventController implements ActionListener { //... The Controller needs to interact with both the Model and View. private EventModel model; private EventView view; /** Constructor */ public EventController(EventModel model, EventView v){ model = new EventModel(); view = v; //... Add listeners to the view. view.addEventListener(new addEventListener()); //view.clearListener(new clearEventListener()); view.addDialog(new addDialogListener()); view.editDialog(new editDialogListener()); } class addEventListener implements ActionListener { public void actionPerformed(ActionEvent e) { String name = ""; String date; String start=""; String end=""; String venue=""; String details=""; String opportunities=""; String moreOppor=""; try { name = view.getEventName(); date = view.eventDate().toString(); start = view.startTime(); end = view.endTime(); venue = view.locationWhere(); details = view.getDetails(); opportunities = view.getOpportunities(); moreOppor = view.getMore(); model.addEvent(name,date,start,venue,details,opportunities,moreOppor,end); view.showSuccess("Event Added!"); } catch (Exception ex) { view.showError(ex); } } } class addDialogListener implements ActionListener { @Override public void actionPerformed(ActionEvent e) { System.out.println(""); } } class editDialogListener implements ActionListener { @Override public void actionPerformed(ActionEvent e) { System.out.println(""); } } </code></pre> <p>I have two question in relation to this module:</p> <ol> <li><p><code>EventController</code> is showing an error that it is not abstract and does not override abstract method actionPerformed when I believe I did. Correct me if im wrong. I do have an additional JMenuItem called <code>deleteEvent</code> but I havent touched that yet. Working on NetbeansIDE F.Y.I</p></li> <li><p>I would like to replace the lines <code>System.out.println("");</code> with something that will allow me to display the dialog <code>addDialog</code> of the view class but I cannot access the component. how to do this? I've tried <code>view.</code> but it doesnt show up allow for <code>setVisible(true)</code> . </p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload