/** * Opens a file. If the file can be opened, get a drawing time estimate, update recent files list, * and repaint the preview tab. * * @param filename what file to open */ public void LoadGCode(String filename) { CloseFile(); try { Scanner scanner = new Scanner(new FileInputStream(filename)); linesTotal = 0; gcode = new ArrayList<String>(); try { while (scanner.hasNextLine()) { gcode.add(scanner.nextLine()); ++linesTotal; } } finally { scanner.close(); } } catch (IOException e) { Log("<span style='color:red'>File could not be opened.</span>\n"); RemoveRecentFile(filename); return; } previewPane.setGCode(gcode); fileOpened = true; EstimateDrawTime(); UpdateRecentFiles(filename); Halt(); }