当前位置: 首页>>代码示例>>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;未经允许,请勿转载。