Results 1 to 3 of 3
  1. #1
    skorpionking is offline Member
    Join Date
    Nov 2009
    Posts
    5
    Rep Power
    0

    Default JFileChooser filename autocompletion

    Hello together,

    I'm searching for a posibility to complete the filename in a JFileChooser automatically.

    Example:
    The FileChooser opens a directory with different files, like:

    Test1.txt
    test.csv
    test345.txt
    ...

    If I type e.g. "T" || "t", then the text of the filename-field should be completet to "Test1.txt" || "Test345.txt".

    If someone know a way to activate this function in the JFileChooser, please write an answer to this thread.

    Thanks !!!!

  2. #2
    skorpionking is offline Member
    Join Date
    Nov 2009
    Posts
    5
    Rep Power
    0

    Default [resolved] JFileChooser filename autocompletion

    Problem is resolved by using a FileDialog instead of a JFileChooser.

  3. #3
    holyvincent is offline Member
    Join Date
    Mar 2011
    Posts
    4
    Rep Power
    0

    Default text field cannot be accessed directly

    if one has add auto functionality then he/she has to access the text field but that is not possible in normal ways..

    A kind of hack was is there which searches for all the components and then finds the instance of textfield and returns it.

    here is the code.. :)
    Java Code:
    private  JTextField dis(JFileChooser jf) {
            boolean hide =false;
            LinkedList<Component> queue = new LinkedList<Component>();
            queue.add(jf);
            JTextField jtf=new JTextField();
            while(queue.size() != 0) {
                Component[] c = ((Container) queue.removeFirst()).getComponents();   
                for(int i = 0; i < c.length; i++) {                        
                    queue.add(c[i]);    
                                
                    if(c[i] instanceof JTextField) {
                        jtf = (JTextField) c[i];
                        jtf.setVisible(true);
                        jtf.setEnabled(true);
                        jtf.setText(" hello ");
                        return jtf;
                    }
                        
                        
            }           
        }
        
        
        return jtf;
      }
    and here is the link for class extends JFileChooser that applies autocomplete

    http://commondatastorage.googleapis....ser/VinFC.java

Similar Threads

  1. New filename after try catch
    By hellzxmaker in forum New To Java
    Replies: 3
    Last Post: 11-05-2010, 11:07 PM
  2. Replies: 4
    Last Post: 04-03-2010, 06:20 PM
  3. How to create jTextField autocompletion
    By radix in forum New To Java
    Replies: 6
    Last Post: 11-08-2008, 03:55 PM
  4. Filename Filter problem
    By KevMeistr in forum Advanced Java
    Replies: 2
    Last Post: 06-14-2008, 02:43 AM
  5. Reading a directory and getting the filename
    By mrjunsy in forum Advanced Java
    Replies: 1
    Last Post: 05-10-2008, 02:36 AM

Tags for this Thread

Posting Permissions

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