-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathController.java
More file actions
39 lines (33 loc) · 1.48 KB
/
Controller.java
File metadata and controls
39 lines (33 loc) · 1.48 KB
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
package controller;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileNameExtensionFilter;
import controller.actionlistener.OpenActionListener;
import view.TextEditorFrame;
import view.jmenuitem.BaseItem;
/**
* Description
*
* @author swkumar (swkumar@groupon.com)
* @since 1.0.0
*/
public class Controller {
private final TextEditorFrame textEditorFrame = new TextEditorFrame();
private final JFileChooser fileExplorer = new JFileChooser();
public Controller() {
//You could create it's own controller that you can call in this big controller.
//something like JMenuItemController menuItemController = new JMenuItemController();
//menuItemController.control();
String filePath = "C:/Users/Dhruv/Desktop/Java Course Materials/"; //default file path name - yet to be given by professor!
fileExplorer.setCurrentDirectory(new File(filePath)); // 'Citation: From the problem statement (example)'
FileNameExtensionFilter filter = new FileNameExtensionFilter("Text files", "txt"); // Filter to accept only file with .txt extension
fileExplorer.setFileFilter(filter);
BaseItem openItem = textEditorFrame
.getTextEditorMenuBar()
.getFileMenu()
.getOpenItem();
textEditorFrame
.getTextEditorMenuBar()
.getFileMenu().addItemActionListener(openItem, new OpenActionListener(fileExplorer, textEditorFrame));
}
}