javax.swing.JFileChooser#updateUI ( )源码实例Demo

下面列出了javax.swing.JFileChooser#updateUI ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: chipster   文件: RemoteSessionChooserFactory.java
public static ServerFileSystemView updateRemoteSessions(SessionManager sessionManager,
		JFileChooser sessionFileChooser, boolean excludeExampleSessions) throws FileBrokerException, MalformedURLException, AuthCancelledException {
	List<DbSession> sessions = sessionManager.listRemoteSessions();
	
	// hide example sessions
	if (excludeExampleSessions) {
		List<DbSession> sessionsToHide = new LinkedList<DbSession>();
		for (DbSession session: sessions) {
			if (session.getName().startsWith(DerbyMetadataServer.DEFAULT_EXAMPLE_SESSION_FOLDER)) {
				sessionsToHide.add(session);
			}
		}
		sessions.removeAll(sessionsToHide);
	}
		
	ServerFileSystemView view = ServerFileSystemView.parseFromPaths(ServerFile.SERVER_SESSION_ROOT_FOLDER, sessions);		
	sessionFileChooser.setFileSystemView(view);
	// without this the GUI doesn't update when a session is removed
	sessionFileChooser.setCurrentDirectory(null);
	sessionFileChooser.setCurrentDirectory(view.getRoot());		
	sessionFileChooser.putClientProperty("sessions", sessions);
	// without this removed sessions are shown after folder change
	sessionFileChooser.updateUI();
	return view;
}
 
源代码2 项目: tracker   文件: Upgrader.java
/**
 * Uses a JFileChooser to select a download directory.
 * 
 * @param parent a component to own the file chooser
 * @param likely the default likely directory
 * @return the chosen directory file
 */
private File chooseDownloadDirectory(Component parent, File likely) {

	JFileChooser chooser = new JFileChooser() {
    public void approveSelection() {
        if (getSelectedFile().isFile()) {
            return;
        } else
            super.approveSelection();
    }
};
  chooser.setDialogTitle(TrackerRes.getString("TTrackBar.Chooser.DownloadDirectory")); //$NON-NLS-1$		
  chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  javax.swing.filechooser.FileFilter folderFilter = new javax.swing.filechooser.FileFilter() {
    // accept directories only
    public boolean accept(File f) {
    	if (f==null) return false;
    	if (f.getName().endsWith(".app")) return false; //$NON-NLS-1$
      return f.isDirectory();
    }
    public String getDescription() {
      return ToolsRes.getString("LibraryTreePanel.FolderFileFilter.Description"); //$NON-NLS-1$
    } 	     	
  };
  chooser.setAcceptAllFileFilterUsed(false);
  chooser.addChoosableFileFilter(folderFilter);
  chooser.setCurrentDirectory(new File(likely.getParent()));
  chooser.setSelectedFile(likely);
  if (OSPRuntime.isMac()) {
  	chooser.updateUI();
  }
	FontSizer.setFonts(chooser, FontSizer.getLevel());
 int result = chooser.showDialog(parent, TrackerRes.getString("Dialog.Button.OK")); //$NON-NLS-1$
  if (result==JFileChooser.APPROVE_OPTION) {
    return chooser.getSelectedFile();
  }
	return null;
}