當前位置: 首頁>>代碼示例>>Java>>正文


Java FileSystemView類代碼示例

本文整理匯總了Java中javax.swing.filechooser.FileSystemView的典型用法代碼示例。如果您正苦於以下問題:Java FileSystemView類的具體用法?Java FileSystemView怎麽用?Java FileSystemView使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


FileSystemView類屬於javax.swing.filechooser包,在下文中一共展示了FileSystemView類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compile

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
@Override
public void compile() {
    File file = new File(FileSystemView.getFileSystemView().getDefaultDirectory().getPath() + "/ezTex");
    File[] files = file.listFiles();
    System.out.println("Wähle eine Datei aus:");
    for (int i = 0; i < files.length; i++)
        System.out.println("\t" + i + ": " + files[i].getName());

    int chosen = sc.nextInt();
    if (chosen > files.length)
        return;

    File chosenFile = new File(files[chosen].getAbsolutePath() + "/" + files[chosen].getName() + ".eztex");

    System.out.println(chosenFile.getAbsolutePath());

    startCompiler(readFile(chosenFile), chosenFile);
}
 
開發者ID:DragonCoder01,項目名稱:ezTeX-FatherCompiler,代碼行數:19,代碼來源:App.java

示例2: createShortcut

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
/** ������ݷ�ʽ */
private void createShortcut() {
	 // ��ȡϵͳ����·��
       String desktop = FileSystemView.getFileSystemView().getHomeDirectory().getAbsolutePath();
       // ����ִ���ļ�·��
       String appPath = System.getProperty("user.dir");
       File exePath = new File(appPath).getParentFile();

       JShellLink link = new JShellLink();
       link.setFolder(desktop);
       link.setName("Notebook.exe");
       link.setPath(exePath.getAbsolutePath() + File.separator + "Notebook.exe");
       // link.setArguments("form");
       link.save();
       System.out.println("======== create success ========");
}
 
開發者ID:coding-dream,項目名稱:Notebook,代碼行數:17,代碼來源:App.java

示例3: testValidRoots

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
public void testValidRoots () throws Exception {
    assertNotNull(testedFS.getRoot());    
    assertTrue(testedFS.getRoot().isValid());            
    
    FileSystemView fsv = FileSystemView.getFileSystemView();                
    File[] roots = File.listRoots();
    boolean validRoot = false;
    for (int i = 0; i < roots.length; i++) {
        FileObject root1 = FileUtil.toFileObject(roots[i]);
        if (!roots[i].exists()) {
           assertNull(root1);
           continue; 
        }
        
        assertNotNull(roots[i].getAbsolutePath (),root1);
        assertTrue(root1.isValid());
        if (testedFS == root1.getFileSystem()) {
            validRoot = true;
        }
    }
    assertTrue(validRoot);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:BaseFileObjectTestHid.java

示例4: testNormalizeDrivesOnWindows48681

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
public void testNormalizeDrivesOnWindows48681 () {
    if ((Utilities.isWindows () || (Utilities.getOperatingSystem () == Utilities.OS_OS2))) {
        File[] roots = File.listRoots();
        for (int i = 0; i < roots.length; i++) {
            File file = roots[i];
            if (FileSystemView.getFileSystemView().isFloppyDrive(file) || !file.exists()) {
                continue;
            }
            File normalizedFile = FileUtil.normalizeFile(file);
            File normalizedFile2 = FileUtil.normalizeFile(new File (file, "."));
            
            assertEquals (normalizedFile.getPath(), normalizedFile2.getPath());
        }
        
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:BaseFileObjectTestHid.java

示例5: getCurrentDirectory

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
private static File getCurrentDirectory() {
    if (Boolean.getBoolean("netbeans.openfile.197063")) {
        // Prefer to open from parent of active editor, if any.
        TopComponent activated = TopComponent.getRegistry().getActivated();
        if (activated != null && WindowManager.getDefault().isOpenedEditorTopComponent(activated)) {
            DataObject d = activated.getLookup().lookup(DataObject.class);
            if (d != null) {
                File f = FileUtil.toFile(d.getPrimaryFile());
                if (f != null) {
                    return f.getParentFile();
                }
            }
        }
    }
    // Otherwise, use last-selected directory, if any.
    if(currentDirectory != null && currentDirectory.exists()) {
        return currentDirectory;
    }
    // Fall back to default location ($HOME or similar).
    currentDirectory =
            FileSystemView.getFileSystemView().getDefaultDirectory();
    return currentDirectory;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:OpenFileAction.java

示例6: doDirectoryChanged

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
private void doDirectoryChanged(PropertyChangeEvent e) {
	JFileChooser fc = getFileChooser();
	FileSystemView fsv = fc.getFileSystemView();

	clearIconCache();

	File currentDirectory = fc.getCurrentDirectory();
	this.fileList.updatePath(currentDirectory);

	if (currentDirectory != null) {
		this.directoryComboBoxModel.addItem(currentDirectory);
		getNewFolderAction().setEnabled(currentDirectory.canWrite());
		getChangeToParentDirectoryAction().setEnabled(!fsv.isRoot(currentDirectory));
		getChangeToParentDirectoryAction().setEnabled(!fsv.isRoot(currentDirectory));
		getGoHomeAction().setEnabled(!userHomeDirectory.equals(currentDirectory));

		if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
			if (fsv.isFileSystem(currentDirectory)) {
				setFileName(currentDirectory.getPath());
			} else {
				setFileName(null);
			}
			setFileSelected();
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:27,代碼來源:FileChooserUI.java

示例7: checkForUpdate

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
public static Optional<String> checkForUpdate() throws IOException {
	File oldJar = new File(new File(FileSystemView.getFileSystemView().getDefaultDirectory(), "OneClient"), "temp_update.jar");
	if (oldJar.exists()) {
		oldJar.delete();
	}
	String json = "";
	try {
		json = IOUtils.toString(new URL(updateURL), StandardCharsets.UTF_8);
	} catch (UnknownHostException e) {
		OneClientLogging.error(e);
		return Optional.empty();
	}
	LauncherUpdate launcherUpdate = JsonUtil.GSON.fromJson(json, LauncherUpdate.class);
	if (Constants.getVersion() == null) {
		return Optional.empty();
	}
	if (launcherUpdate.compareTo(new LauncherUpdate(Constants.getVersion())) > 0) {
		return Optional.of(launcherUpdate.latestVersion);
	}
	return Optional.empty();
}
 
開發者ID:HearthProject,項目名稱:OneClient,代碼行數:22,代碼來源:Updater.java

示例8: main

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
public static void main(String[] args) {
    File dir = FileSystemView.getFileSystemView().getDefaultDirectory();

    printDirContent(dir);

    System.setSecurityManager(new SecurityManager());

    // The next test cases use 'dir' obtained without SecurityManager

    try {
        printDirContent(dir);

        throw new RuntimeException("Dir content was derived bypass SecurityManager");
    } catch (AccessControlException e) {
        // It's a successful situation
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:bug6484091.java

示例9: loadWorld

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
@Override
public void loadWorld() {
    FileSystemView vueSysteme = FileSystemView.getFileSystemView();

    File defaut = vueSysteme.getDefaultDirectory();

    JFileChooser fileChooser = new JFileChooser(defaut);
    fileChooser.showDialog(this, "Load");
    if(fileChooser.getSelectedFile() != null){
        File file = new File(fileChooser.getSelectedFile().getAbsolutePath());

        FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "txt", "Map Loader");
        fileChooser.setFileFilter(filter);

        try {

            this.mapDao.addMap(WorldLoader.genRawMapFILE(file));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:Exia-Aix-A2,項目名稱:Boulder-Dash,代碼行數:23,代碼來源:Menu.java

示例10: main

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
    if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
            OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) > 0 ) {
        FileSystemView fsv = FileSystemView.getFileSystemView();
        for (File file : fsv.getFiles(fsv.getHomeDirectory(), false)) {
            if(file.isDirectory()) {
                for (File file1 : fsv.getFiles(file, false)) {
                    if(file1.isDirectory())
                    {
                        String path = file1.getPath();
                        if(path.startsWith("::{") &&
                                path.toLowerCase().endsWith(".library-ms")) {
                            throw new RuntimeException("Unconverted library link found");
                        }
                    }
                }
            }
        }
    }
    System.out.println("ok");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:bug8003399.java

示例11: checkBrowser

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
public static boolean checkBrowser() {
    AppList appList = MimeTypesList.getAppList();
    String bpath = appList.getBrowserExec();
    if (bpath != null)
        if (new File(bpath).isFile())
            return true;
    File root = new File(System.getProperty("user.home"));
    FileSystemView fsv = new SingleRootFileSystemView(root);
    JFileChooser chooser = new JFileChooser(fsv);
    chooser.setFileHidingEnabled(true);
    chooser.setDialogTitle(Local.getString("Select the web-browser executable"));
    chooser.setAcceptAllFileFilterUsed(true);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    /*java.io.File lastSel = (java.io.File) Context.get("LAST_SELECTED_RESOURCE_FILE");
    if (lastSel != null)
        chooser.setCurrentDirectory(lastSel);*/
    if (chooser.showOpenDialog(App.getFrame()) != JFileChooser.APPROVE_OPTION)
        return false;
    appList.setBrowserExec(chooser.getSelectedFile().getPath());
    CurrentStorage.get().storeMimeTypesList();
    return true;
}
 
開發者ID:cst316,項目名稱:spring16project-Team-Laredo,代碼行數:23,代碼來源:Util.java

示例12: getDiskInfo

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
/***
 * Get Disk information.
 */
private static void getDiskInfo(){
	File[] drives = File.listRoots();
	
	systemDiskUsage.clear();
	systemInfo.clear();
	
	if(drives != null && drives.length > 0){
		for(File disk : drives){
			long totalSpace = disk.getTotalSpace();
			long usedSpace = totalSpace - disk.getFreeSpace();
			double usage = (double)usedSpace * 100 / (double)totalSpace;
			systemDiskUsage.put(disk.toString(), usage);
			
			FileSystemView fsv = FileSystemView.getFileSystemView();
			systemInfo.put(disk.toString(), fsv.getSystemTypeDescription(disk));
		}
	}
}
 
開發者ID:ParkJinSang,項目名稱:Jinseng-Server,代碼行數:22,代碼來源:ServerStatus.java

示例13: createImageIconView

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
/**
 * 파일로부터 이미지를 그리기 위한 뷰를 반환한다.
 *
 * @Date 2015. 10. 14.
 * @param file
 * @return
 * @User KYJ
 */
public static ImageView createImageIconView(File file) {
	Image fxImage = null;
	if (file.exists()) {
		FileSystemView fileSystemView = FileSystemView.getFileSystemView();
		Icon icon = fileSystemView.getSystemIcon(file);

		BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
		icon.paintIcon(null, bufferedImage.getGraphics(), 0, 0);
		fxImage = SwingFXUtils.toFXImage(bufferedImage, null);
	} else {
		return new ImageView();
	}

	return new ImageView(fxImage);
}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:24,代碼來源:FxUtil.java

示例14: cleanUp

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
public static void cleanUp() {
  //gets rid of scratch files.
  FileSystemView Directories = FileSystemView.getFileSystemView();
  File homedir = Directories.getHomeDirectory();
  String homedirpath = homedir.getPath();
  String scratchpath = homedirpath + "/.jmol_WPM";
  File scratchdir = new File(scratchpath);
  if (scratchdir.exists()) {
    File[] dirListing = null;
    dirListing = scratchdir.listFiles();
    for (int i = 0; i < (dirListing.length); i++) {
      dirListing[i].delete();
    }
  }
  saveHistory();//force save of history.
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:17,代碼來源:WebExport.java

示例15: setup

import javax.swing.filechooser.FileSystemView; //導入依賴的package包/類
protected void setup(FileSystemView view)
   {
super.setup(view);
removeChoosableFileFilter(getAcceptAllFileFilter());

xml = new SuffixedFileFilter("xml");
addChoosableFileFilter(xml);

msAccess = new SuffixedFileFilter("mdb");
addChoosableFileFilter(msAccess);

fileMaker = new SuffixedFileFilter("fmp");
addChoosableFileFilter(fileMaker);

odbc = new SuffixedFileFilter("dsn");
addChoosableFileFilter(odbc);

addChoosableFileFilter(getAcceptAllFileFilter());
setFileFilter(xml);
   }
 
開發者ID:nomencurator,項目名稱:taxonaut,代碼行數:21,代碼來源:SuffixedFileChooser.java


注:本文中的javax.swing.filechooser.FileSystemView類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。