// public static final String showElementTreeAction = "showElementTree"; // ------------------------------------------------------------- public void openFile(String currDirStr, String currFileStr) { if (fileDialog == null) { fileDialog = new FileDialog(this); } fileDialog.setMode(FileDialog.LOAD); if (!(currDirStr.equals(""))) { fileDialog.setDirectory(currDirStr); } if (!(currFileStr.equals(""))) { fileDialog.setFile(currFileStr); } fileDialog.show(); String file = fileDialog.getFile(); // cancel pushed if (file == null) { return; } String directory = fileDialog.getDirectory(); File f = new File(directory, file); if (f.exists()) { Document oldDoc = getEditor().getDocument(); if (oldDoc != null) // oldDoc.removeUndoableEditListener(undoHandler); /* if (elementTreePanel != null) { elementTreePanel.setEditor(null); } */ getEditor().setDocument(new PlainDocument()); fileDialog.setTitle(file); Thread loader = new FileLoader(f, editor1.getDocument()); loader.start(); } }
public void loadROM() { FileDialog fileDialog = new FileDialog(this); fileDialog.setMode(FileDialog.LOAD); fileDialog.setTitle("Select a ROM to load"); // should open last folder used, and if that doesn't exist, the folder it's running in final String path = PrefsSingleton.get().get("filePath", System.getProperty("user.dir", "")); final File startDirectory = new File(path); if (startDirectory.isDirectory()) { fileDialog.setDirectory(path); } // and if the last path used doesn't exist don't set the directory at all // and hopefully the jFileChooser will open somewhere usable // on Windows it does - on Mac probably not. fileDialog.setFilenameFilter(new NESFileFilter()); boolean wasInFullScreen = false; if (inFullScreen) { wasInFullScreen = true; // load dialog won't show if we are in full screen, so this fixes for now. toggleFullScreen(); } fileDialog.setVisible(true); if (fileDialog.getFile() != null) { PrefsSingleton.get().put("filePath", fileDialog.getDirectory()); loadROM(fileDialog.getDirectory() + fileDialog.getFile()); } if (wasInFullScreen) { toggleFullScreen(); } }