Results 1 to 6 of 6

Thread: FileChooser UI

  1. #1
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default FileChooser UI

    Is it possible to change the UI or L&F of the FileChooser since the icon color used are a bit dull and not the same as window-default icons ?
    If it is possible, i would like to make the filechooser's openDialog the same as the window's openDialog..

    Thanks,
    Hearty

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

  3. #3
    heartysnowy's Avatar
    heartysnowy is offline Member
    Join Date
    Nov 2008
    Posts
    37
    Rep Power
    0

    Default

    no i don't...i used JFileChooser..
    are u implying that only JFileUser would be able to change the UI of the dialog box?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default

    The old FileDialog has a more system-dependent appearance. Also, if you setWindows L&F, JFileChooser methods use the native resource.

    db

  5. #5
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    You can change icons in the JFIleChooser with those lines:

    Java Code:
    public class FileSystem extends JFileChooser{
    
    	public FileSystem(String title){
    		super(title);
    		
    		//icons for the JFileChooser
    		UIManager.put("FileView.directoryIcon", new ImageIcon(FileSystem.class.getResource("folder.png")));
    		UIManager.put("FileChooser.homeFolderIcon", new ImageIcon(FileSystem.class.getResource("user-home.png")));
    		UIManager.put("FileView.computerIcon", new ImageIcon(FileSystem.class.getResource("computer.png")));
    		UIManager.put("FIleView.floppyDriveIcon", new ImageIcon(FileSystem.class.getResource("media-floppy.png")));
    		UIManager.put("FileView.hardDriveIcon", new ImageIcon(FileSystem.class.getResource("drive-harddisk.png")));
    		UIManager.put("FileView.fileIcon", new ImageIcon(FileSystem.class.getResource("file.png")));
    		UIManager.put("FileChooser.upFolderIcon", new ImageIcon(FileSystem.class.getResource("go.png")));
    		UIManager.put("FileChooser.newFolderIcon", new ImageIcon(FileSystem.class.getResource("folder-new.png")));
    		UIManager.put("FileView.fileIcon", new ImageIcon(FileSystem.class.getResource("file.png")));
    		UIManager.put("FileChooser.listViewIcon", new ImageIcon(FileSystem.class.getResource("listIcon.png")));
    		UIManager.put("FileChooser.detailsViewIcon", new ImageIcon(FileSystem.class.getResource("details.png")));
    		SwingUtilities.updateComponentTreeUI(this);
    		
    	}
    
    }
    and to change the names of the label in JFileChooser :
    Java Code:
                    JFileChooser chooser=new JFileChooser("Open");
    //sets the text and language of all the components in JFileChooser
    		UIManager.put("FileChooser.openDialogTitleText", "Open");
    		UIManager.put("FileChooser.lookInLabelText", "LookIn");
    		UIManager.put("FileChooser.openButtonText", "Open");
    		UIManager.put("FileChooser.cancelButtonText", "Cancel");
    		UIManager.put("FileChooser.fileNameLabelText", "FileName");
    		UIManager.put("FileChooser.filesOfTypeLabelText", "TypeFiles");
    		UIManager.put("FileChooser.openButtonToolTipText", "OpenSelectedFile");
    		UIManager.put("FileChooser.cancelButtonToolTipText","Cancel");
    		UIManager.put("FileChooser.fileNameHeaderText","FileName");
    		UIManager.put("FileChooser.upFolderToolTipText", "UpOneLevel");
    		UIManager.put("FileChooser.homeFolderToolTipText","Desktop");
    		UIManager.put("FileChooser.newFolderToolTipText","CreateNewFolder");
    		UIManager.put("FileChooser.listViewButtonToolTipText","List");
    		UIManager.put("FileChooser.newFolderButtonText","CreateNewFolder");
    		UIManager.put("FileChooser.renameFileButtonText", "RenameFile");
    		UIManager.put("FileChooser.deleteFileButtonText", "DeleteFile");
    		UIManager.put("FileChooser.filterLabelText", "TypeFiles");
    		UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
    		UIManager.put("FileChooser.fileSizeHeaderText","Size");
    		UIManager.put("FileChooser.fileDateHeaderText", "DateModified");
    		SwingUtilities.updateComponentTreeUI(chooser);
    TheUI and LookAndFeel try to do with SynthLookAndFeel
    Last edited by serjant; 11-26-2008 at 02:08 PM.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Darryl.Burke View Post
    The old FileDialog has a more system-dependent appearance. Also, if you setWindows L&F, JFileChooser methods use the native resource.

    db
    That's why I think the best way to keep the L&F in a define way is JFileChooser.

Similar Threads

  1. Filechooser
    By Joe2003 in forum New To Java
    Replies: 5
    Last Post: 02-26-2009, 08:51 AM

Posting Permissions

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