-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsController.java
56 lines (49 loc) · 1.66 KB
/
SettingsController.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Last Modified: November 1, 2020
* Author: Shalee (Shahrukh) Qureshi
* Description: This class creates the Controller for the SettingsView
*
* Constructor List:
* 1. SettingsController(ListModel model)
*
* Method List:
* 1. public void valueChanged(ListSelectionEvent e) = This method updates the state of the JSplitPane when a new list item is selected
* 2. public void actionPerformed(ActionEvent e) = This method performs an action upon events on the JComponents
*
*/
// Import Statements
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class SettingsController implements ListSelectionListener, ActionListener {
// Instance Variables
private SettingsModel model;
/**
* This is the SettingsController Constructor
*
* @param model
*/
public SettingsController(SettingsModel model) {
this.model = model;
} // SettingsController Constructor
@Override
/**
* This method updates the state of the JSplitPane when a new list item is
* selected
*
* @param e
*/
public void valueChanged(ListSelectionEvent e) {
this.model.updateState(); // Invoking the update state method whenever a list item is changed
} // valueChanged Method
@Override
/**
* This method performs an action upon events on the JComponents
*
* @param e
*/
public void actionPerformed(ActionEvent e) {
this.model.performAction(e.getActionCommand()); // Performing an action based on the button clicked
} // actionPerformed Method
} // SettingsController Method