Results 1 to 1 of 1
  1. #1
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Default [HELP]JFileChooser unable to show shortcuts/linked folder (.lnk files)

    Hi,

    When I browse into a Folder it shows the contents of that folder but when I browse to a shortcut it doesn't show its content.

    Please how can I display content of the shortcut folder?

    Browse Folder:
    [HELP]JFileChooser unable to show shortcuts/linked folder (.lnk files)-4-8-2013-3-45-23-pm.png


    Browse thru shortcuts(notice that it unable to show its content)
    [HELP]JFileChooser unable to show shortcuts/linked folder (.lnk files)-4-8-2013-3-45-23-pm.png

    Here's the code:
    Java Code:
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import java.io.File;
    import java.util.Vector;
    
    import javax.swing.AbstractAction;
    import javax.swing.JDialog;
    import javax.swing.JFileChooser;
    import javax.swing.JPanel;
    import javax.swing.filechooser.FileView;
    
    import com.safeway.Process.LookAndFeel;
    
    public class FileChooserGui{
    	private JDialog dialog;
    	public FileChooserGui() {
    		LookAndFeel.setLookAndFeel();
    		
    
    		JDialog.setDefaultLookAndFeelDecorated(true);
    		
    		dialog = new JDialog();
    		
    		String desktopPath = System.getProperty("user.home") + "/Desktop";
    
    		if (desktopPath.isEmpty()) {
    			chooser = new JFileChooser();
    		} else {
    			chooser = new JFileChooser(desktopPath.replace("\\", "/"));
    		}
    
    		dialog.setLayout(null);
    		dialog.setModal(true);
    		dialog.getContentPane().setLayout(null);
    
    		chooser.setAcceptAllFileFilterUsed(false);
    		chooser.setCurrentDirectory(null);
    		
    		chooser.setDialogType(JFileChooser.OPEN_DIALOG);
    		chooser.setApproveButtonText("Select");
    		chooser.setApproveButtonMnemonic(KeyEvent.VK_S);
    		chooser.setFileHidingEnabled(true);
    		
    		chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    		chooser.addActionListener(new AbstractAction() {
    			public void actionPerformed(ActionEvent evt) {
    				JFileChooser chooser = (JFileChooser) evt.getSource();
    				if (JFileChooser.APPROVE_SELECTION.equals(evt
    						.getActionCommand())) {
    					chooser.setMultiSelectionEnabled(false);
    					String fileDir = chooser.getSelectedFile().toString();
    					setDirectoryFolder(fileDir);
    
    					setIsHitOk(true);
    					dialog.dispose();
    				} else if (JFileChooser.CANCEL_SELECTION.equals(evt
    						.getActionCommand())) {
    					dialog.dispose();
    					setIsHitOk(false);
    				}
    			}
    		});
    
    		hideSaveAsPanel(chooser);
    		dialog.getContentPane().add(chooser);
    		chooser.setBounds(0, 0, 600, 300);
    
    		dialog.setResizable(false);
    		MyFrame.frameInitialization(dialog, "Workbrain", 600, 330, true, true,
    				true);
    	}
    
    	public static void getFileChooserFolder() {
    		FileChooserGui fc = new FileChooserGui();
    	}
    	
    	protected boolean hideSaveAsPanel(Container c) {
    		Component[] cmps = c.getComponents();
    		for (Component cmp : cmps) {
    			if (cmp instanceof JPanel) {
    				((JPanel) cmp).setVisible(false);
    				return true;
    			}
    			if (cmp instanceof Container) {
    				if (hideSaveAsPanel((Container) cmp))
    					return true;
    			}
    		}
    		return false;
    	}
    
    	protected static JFileChooser chooser;
    	public static Vector<String> fileDirString;
    	private static String directoryFolder;
    	private static boolean isHitOk;
    
    	public static String getDirectoryFolder() {
    		return directoryFolder;
    	}
    
    	public static void setDirectoryFolder(String df) {
    		directoryFolder = df;
    	}
    
    	public static boolean isHitOk() {
    		return isHitOk;
    	}
    
    	public void setIsHitOk(boolean isHitOk) {
    		this.isHitOk = isHitOk;
    	}
    }
    Last edited by RichersooN; 04-08-2013 at 10:52 AM.

Similar Threads

  1. Replies: 10
    Last Post: 05-08-2012, 06:17 AM
  2. Replies: 4
    Last Post: 02-18-2012, 08:37 PM
  3. JFileChooser : Files and Directories
    By captainpirate in forum AWT / Swing
    Replies: 4
    Last Post: 02-02-2012, 09:20 PM
  4. Replies: 4
    Last Post: 04-13-2011, 04:35 AM
  5. JFileChooser - sequential files treatment
    By althair in forum AWT / Swing
    Replies: 2
    Last Post: 01-03-2010, 04:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •