-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileLoader.pde
39 lines (28 loc) · 956 Bytes
/
fileLoader.pde
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
void loadFile() {
File ourFile = getFile();
//get the file path
String fullPath = ourFile.getPath();
String fileName = ourFile.getName();
if ( !fileName.equals("data") ) {
println( fileName );
filePath.setText( fileName );
myCNC.setFileToRun( ourFile );
}
}
File getFile() {
File selectedFile = new File(dataPath("gCode-72.0ppi-6.0x6.0.nc"));
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
e.printStackTrace();
}
// create a file chooser
final JFileChooser fc = new JFileChooser( dataPath("") );
// in response to a button click:
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
selectedFile = fc.getSelectedFile();
}
return selectedFile;
}