JFileChooser feature

Hello all,
I need to know how could I integrate type-ahead feature into JFileChooser. I have been able to put in FileFilter in the JFileChooser dialog but I cant' seem to figure out how to put in type-ahead feature which causes JFileChooser to jump to a file whose corresponding first letter typed by the user.
        final JFileChooser fc = new JFileChooser (lastDirSelected);
        fc.setDialogTitle("Select Children File");
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
         javax.swing.filechooser.FileFilter fi =   new javax.swing.filechooser.FileFilter () {
          private String des = "Xml Files (*.xml)";
          public boolean accept (File f) {
            String name = f.getName();
            String temp[] = name.split("\\.");
            int length = temp.length;
            String ext = temp[length-1].toLowerCase();
            if (f.isDirectory()){
              return true;
            if(ext.equals("xml")){
              return true ;
            } else {
              return false;
          public String getDescription () {
            return des;
        fc.setFileFilter(fi);
        fc.setApproveButtonText("Select");
        fc.setApproveButtonMnemonic('S');
        int returnVal = fc.showOpenDialog (this);
        if (returnVal == fc.APPROVE_OPTION) {
            childXmlFile = fc.getSelectedFile ().toString ();
            childInfoFileText.setText (childXmlFile);
         }The above code is a working code but there is little problem as well, fc.setApproveButtonMnemonic('S'); does not underline 'S' in "Select". Anyway this issue does not matter to me much, but if anyone of you could get me any solution or advice or suggestion regarding the type-ahead feature, I would be grateful.
Regards
Khurram

http://www.google.com/search?num=100&hl=en&c2coff=1&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=java+typeahead+buffer&spell=1

Similar Messages

  • JFileChooser not showing files on FTP mount..

    I'm using Swing under JDK1.4.2 on a WinXP box.
    I have a Linux box (SuSE 8.1) running an FTP server (vsftpd 1.1.0).
    Running from WinXP, I have added a Network Place to a folder served by that FTP server. From WinXP I can browse that Network Place and all files can be seen.
    When my app presents the file chooser and I navigate to that Network Place the folder shows empty.
    How can I get JFileChooser to show me the files on that FTP mount?
    Thanks,
    --BobC 

    JResourceBrowser is a swing component similar to the javax.swing.JFileChooser but letting the user navigating into a set of directories bound to various protocols or containers. For an usage sample, listing an ftp directory, creating a new file and editing it inside your application. JResourceBrowser is provided by default with a set of "managers" dedicated to ZIP and JAR, FTP and WebDAV.
    http://www.swingall.com/jrb/index.html
    Features :
    * JavaBeans
    * Built with a GridBagLayout
    * Create your own plugins for navigating
    * User Interface delegate for rendering a file
    * Cutomize the set of actions
    * Default actions for creating a new file, deleting, renaming or locking/unlocking
    * Extracting or putting a file content
    * Save/restore the user interface state
    * ZIP, JAR support
    * FTP support
    * WebDAV support
    * JDK 1.4 and 1.5 compatibility

  • Disabling the Open button in the JFileChooser dialog

    Hi,
    I would like to enable/disable the Open button in the JFileChooser dialog, after the dialog is shown.
    I looked at the Java APIs but I could not find a method that gives me the access to this button.
    Could anyone let me know how to either retrieve the Open button from the JFileChooser or enable/disable it through Java APIs?
    Thanks in advance,
    Paul Rodziewicz

    As I'm editing with multiclips in my sequence, if I select "open" from the middle pulldown menu in the canvas or viewer, it will open the multiclip in the viewer and play it in sync with my timeline playhead (like the gang feature). I.E. so I can hit play in my timeline, watch the multiclip in the viewer real time, and make edits (to the clip in the timeline) as I watch. My issue is that the syncing of the viewer playhead and the timeline playhead often break when deleting clips and I constantly have to reselect the "open" button, and it would be way nicer if there was a shortcut key instead of having to mouse it. It only takes a second to use your mouse and select "open" but when you have to do it constantly, it makes you wish for a quick key.
    img src="http://a960.ac-images.myspacecdn.com/images01/47/l_b06e2e3aee5446928b2daca d1d04520f.jpg" align=left width=600 height=463 alt="pic1">pic1
    img src="http://a672.ac-images.myspacecdn.com/images01/60/l_979388c01dd9880126c0fbd 8f5ab49f7.jpg" align=left width=600 height=485 alt="pic2">pic2

  • Changing the file extension by entering a "?" in JFileChooser

    Hi,
    I've encountered a weird thing in JFileChooser. If you open the chooser, type at least one "?" in the field for the filename and then hit the approve button, the file extension will change to the text you entered as the filename.
    To reproduce this problem, simply launch the JWSFileChooserDemo hit the "Open a File..."-button and as the filename enter something like "?deadbeef". Now click the open button and you will see that the file extension changes to "?deadbeef".
    This is a really strange behaviour in my opinion.
    I'm using Windows 7 with java 6u16, but the issue is the same on windows xp sp3. Perhaps on linux too. I'll give it a try as soon as I can.
    Has anyone else encountered that problem?
    Best regards
    Edited by: Wurstsalat on Mar 23, 2010 10:30 AM

    To reproduce this problemThis is not a problem but rather a feature. I did not know of this till now. Thanks for informing.
    As Kevin pointed out this is related to filtering of files.
    ?deadbeefThis will match all the files which start with any letter followed by "deadbeef". So, ? is a wildcard meaning any one character. Other wildcard can be *, which means any number of characters. Try this:
    *.txt
    a*.txt
    *.jp*g
    ??.txt I don't know other wildcards...
    Thanks!

  • JFileChooser problem on MAC OS

    In JavaFX UI on click of Browse button, I am using JFileChooser to open the file system. Below is the piece of code which I am executing and the exception I am getting:
    Later I used DirectoryChooser. This is working fine but the pop-up is always coming behind javafx applet when started in browser.
    Note: This is working fine if we run as stand alone application.
    JFileChooser chooser = new JFileChooser(new File("/Volumes/"));
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int result = chooser.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
    System.out.println("selectedFile: "+chooser.getSelectedFile());
    //tfFileSelected.setText(getParent(chooser.getSelectedFile()));
    2013-03-04 10:16:40.480 java[15576:5803] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
    2013-03-04 10:16:42.614 java[15576:707] [JRSAppKitAWT markAppIsDaemon]: Process manager already initialized: can't fully enable headless mode.
    Glass detected outstanding Java exception at -[GlassViewDelegate sendJavaMouseEvent:]:src/com/sun/mat/ui/GlassViewDelegate.m:541
    Exception in thread "AWT-AppKit" java.awt.HeadlessException
         at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
         at java.awt.Window.<init>(Window.java:535)
         at java.awt.Frame.<init>(Frame.java:420)
         at java.awt.Frame.<init>(Frame.java:385)
         at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1759)
         at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1834)
         at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1697)
         at javax.swing.JOptionPane.getWindowForComponent(JOptionPane.java:1638)
         at javax.swing.JFileChooser.createDialog(JFileChooser.java:785)
         at javax.swing.JFileChooser.showDialog(JFileChooser.java:732)
         at javax.swing.JFileChooser.showOpenDialog(JFileChooser.java:639)
         at samplebrowse.SampleBrowse$1.handle(SampleBrowse.java:46)
         at samplebrowse.SampleBrowse$1.handle(SampleBrowse.java:31)
         at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)
         at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
         at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
         at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
         at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)
         at javafx.event.Event.fireEvent(Event.java:171)
         at javafx.scene.Node.fireEvent(Node.java:6863)
         at javafx.scene.control.Button.fire(Button.java:179)
         at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)
         at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)
         at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)
         at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)
         at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)
         at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)
         at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)
         at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)
         at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)
         at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)
         at javafx.event.Event.fireEvent(Event.java:171)
         at javafx.scene.Scene$MouseHandler.process(Scene.java:3324)
         at javafx.scene.Scene$MouseHandler.process(Scene.java:3164)
         at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3119)
         at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1559)
         at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2261)
         at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:228)
         at com.sun.glass.ui.View.handleMouseEvent(View.java:528)
         at com.sun.glass.ui.View.notifyMouse(View.java:922)
    2013-03-04 10:16:44.769 java[15576:707] unrecognized type is -2
    2013-03-04 10:16:44.770 java[15576:707] *** Assertion failure in -[NSEvent _initWithCGSEvent:eventRef:], /SourceCache/AppKit/AppKit-1187.34/AppKit.subproj/NSEvent.m:1348
    2013-03-04 10:16:44.770 java[15576:707] Invalid parameter not satisfying: cgsEvent.type > 0 && cgsEvent.type <= kCGSLastEventType
    2013-03-04 10:16:44.771 java[15576:707] (
         0 CoreFoundation 0x00007fff952af0a6 __exceptionPreprocess + 198
         1 libobjc.A.dylib 0x00007fff93fc13f0 objc_exception_throw + 43
         2 CoreFoundation 0x00007fff952aeee8 +[NSException raise:format:arguments:] + 104
         3 Foundation 0x00007fff8af8e6a2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
         4 AppKit 0x00007fff8c8da56c -[NSEvent _initWithCGSEvent:eventRef:] + 2782
         5 AppKit 0x00007fff8cb5b3ea +[NSEvent eventWithCGEvent:] + 243
         6 libglass.dylib 0x0000000163f4c02f listenTouchEvents + 31
         7 CoreGraphics 0x00007fff919b20d9 processEventTapData + 150
         8 CoreGraphics 0x00007fff919b1f2c _CGYPostEventTapData + 189
         9 CoreGraphics 0x00007fff9191155d _XPostEventTapData + 107
         10 CoreGraphics 0x00007fff91911655 CGYEventTap_server + 106
         11 CoreGraphics 0x00007fff919b201a eventTapMessageHandler + 30
         12 CoreFoundation 0x00007fff9521e410 __CFMachPortPerform + 288
         13 CoreFoundation 0x00007fff9521e2d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
         14 CoreFoundation 0x00007fff9521e019 __CFRunLoopDoSource1 + 153
         15 CoreFoundation 0x00007fff9525119f __CFRunLoopRun + 1775
         16 CoreFoundation 0x00007fff952506b2 CFRunLoopRunSpecific + 290
         17 HIToolbox 0x00007fff8db930a4 RunCurrentEventLoopInMode + 209
         18 HIToolbox 0x00007fff8db92e42 ReceiveNextEventCommon + 356
         19 HIToolbox 0x00007fff8db92cd3 BlockUntilNextEventMatchingListInMode + 62
         20 AppKit 0x00007fff8c7fb613 _DPSNextEvent + 685
         21 AppKit 0x00007fff8c7faed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
         22 AppKit 0x00007fff8c7f2283 -[NSApplication run] + 517
         23 libglass.dylib 0x0000000163f394e9 -[GlassApplication runLoop:] + 777
         24 Foundation 0x00007fff8b014677 __NSThreadPerformPerform + 225
         25 CoreFoundation 0x00007fff9522e101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
         26 CoreFoundation 0x00007fff9522da25 __CFRunLoopDoSources0 + 245
         27 CoreFoundation 0x00007fff95250dc5 __CFRunLoopRun + 789
         28 CoreFoundation 0x00007fff952506b2 CFRunLoopRunSpecific + 290
         29 java 0x0000000109e274bc CreateExecutionEnvironment + 871
         30 java 0x0000000109e21cac JLI_Launch + 1952
         31 java 0x0000000109e27819 main + 101
         32 java 0x0000000109e21504 start + 52
    )

    "Later I used DirectoryChooser. This is working fine but the pop-up is always coming behind javafx applet when started in browser. Note: This is working fine if we run as stand alone applicationYou should file a bug/feature request about this against the Runtime project:
    http://javafx-jira.kenai.com
    Exception in thread "AWT-AppKit" java.awt.HeadlessExceptionSee:
    http://javafx-jira.kenai.com/browse/RT-20784 "Mac: Headless environment issue, MacOSX"
    The above issue discusses some potential workarounds which may (or may not) work in your situation.
    Try the latest 8-ea build (available at http://jdk8.java.net/download.html).
    The graphics environment is no longer forced to be headless in the java 8 trunk (the jira case I linked is closed as fixed), but it may take a week or two for the fix to propagate to the jdk8 early access download page.
    Also note that this kind of call from a JavaFX application to a Swing component isn't really a supported configuration (embedding JavaFX in a JFXPanel in a Swing application is supported, but other forms of interaction between JavaFX and Swing such as JavaFX opening Swing dialogs are not). That's not to say that it might not work, it's just that you shouldn't expect it to work now or continue to work in the future (especially in an applet deployment context where the window handling is more complex for the underlying frameworks due to the browser embedding). Further facilities to ease Swing and JavaFX integration are planned for JavaFX 8 (http://javafx-jira.kenai.com/browse/RT-12100 "Swing components inside JavaFX"), but I don't know if it would mean that the scenario you are trying to achieve would be supported.
    A further alternative you might have would be to deploy your application as a Swing application rather than a JavaFX application and wrap your JavaFX content in a JFXPanel. It is likely that opening a Swing JFileChooser would work in such a mixed code scenario, though I have not tried it.

  • JFileChooser interpreting zip file as a folder

    I have an app that reads and writes data to zip files. When opening one, I use a JFileChooser with a file filter for zips and directories.
    This works fine except except on XP. If the zip file is on a remote (Novell) file server, the JFileChooser treats the zip file as a directory. You can't open the zip file itself.
    If the client is W2k, there is no problem.
    I'm using JRE 1.4.1.
    Anyone know if there's a tweak to XP to fix this?

    JResourceBrowser is a swing component similar to the javax.swing.JFileChooser but letting the user navigating into a set of directories bound to various protocols or containers. For an usage sample, listing an ftp directory, creating a new file and editing it inside your application. JResourceBrowser is provided by default with a set of "managers" dedicated to ZIP and JAR, FTP and WebDAV.
    http://www.swingall.com/jrb/index.html
    Features :
    * JavaBeans
    * Built with a GridBagLayout
    * Create your own plugins for navigating
    * User Interface delegate for rendering a file
    * Cutomize the set of actions
    * Default actions for creating a new file, deleting, renaming or locking/unlocking
    * Extracting or putting a file content
    * Save/restore the user interface state
    * ZIP, JAR support
    * FTP support
    * WebDAV support
    * JDK 1.4 and 1.5 compatibility

  • JFileChooser - List and Details

    Hi,
    In the JFileChooser Dialog, we have two buttons "List" and "Details" to view and select the files.
    The default is "List" mode, when the File Chooser dialog opens.
    In this mode, if we type in the first character of the file we want to select, then the FileChooser will automatically focus the first file in that directory starting with that letter.
    For Example: If I type in 's' in the "File Name" text filed, the focus is on the first file in that directory starting with letter 's' like "sample.txt".
    But this same feature is not available in the "Details" mode.
    Does anyone have an idea of how to incorporate this in the "Details" mode ?
    Also is there a way to make the "Details" mode as the default mode when the FileChooser dialog opens.
    I have tried many sources but could not find any information regarding this problem.
    Any help will be appreciated.
    Thanks in advance,
    Neeharika.

    Here's a solution. I still think there should be a more official way of doing this.
    public MyFileView(JFileChooser chooser)
              for ( Component c : chooser.getComponents())
                   if (c.getClass() == FilePane.class)
                        filePane = (FilePane) c;
         @Override
         public String getName(File f)
              if (filePane.getViewType() == FilePane.VIEWTYPE_DETAILS){
                   return "Long";
              return null;
         }

  • JFileChooser: changing file type resets current directory

    I create a JFileChooser with multiple file types and set the current directory. It comes up with the first file type and the current directory. If I select another file type, the files shown are not in the current directory, which I set -- they are files in the application default directory. Is there a way to keep my current directory, while changing the file type? Or is this a feature?

    Are you talking about your own CDs imported to iTunes or are you talking about songs purchased from the iTunes Music Store (iTMS)? If the latter, the iTMS, you do not get any choice in the format downloaded. You get protected AAC files and that is all.
    If you want to change how you import files, go to the iTunes preferences for importing and choose the format you want to use from now on.
    Patrick

  • JFileChooser's approve button text changes when file

    I have a JFileChooser used for loading some XML file(s). We want the approve button's text to be "Load". When I bring up the dialog, the button text initially reads "Load", when I select a directory, it reads "Open", if I select a file again, it goes back to "Load". So far, so good.
    The problem comes when using it in a non-English language. When I bring up the dialog, the button text initially reads the appropriately translated "Load". However, when I select a directory, it changes to the English "Open". I do not see a method to use to adjust this text. Am I missing something, or is this a bug?
    Any help is greatly appreciated.
    Jamie

    Here's some code I'll put into the public domain:
    package com.graphbuilder.desktop;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.Stack;
    import java.util.Vector;
    import java.util.StringTokenizer;
    import java.io.File;
    <p>Attempt to improve the behaviour of the JFileChooser.  Anyone who has used the
    the JFileChooser will probably remember that it lacks several useful features.
    The following features have been added:
    <ul>
    <li>Double click to choose a file</li>
    <li>Enter key to choose a file after typing the filename</li>
    <li>Enter key to change to a different directory after typing the filename</li>
    <li>Automatic rescanning of directories</li>
    <li>A getSelectedFiles method that returns the correct selected files</li>
    <li>Escape key cancels the dialog</li>
    <li>Access to common GUI components, such as the OK and Cancel buttons</li>
    <li>Removal of the useless Update and Help buttons in Motif L&F</li>
    </ul>
    <p>There are a lot more features that could be added to make the JFileChooser more
    user friendly.  For example, a drop-down combo-box as the user is typing the name of
    the file, a list of currently visited directories, user specified file filtering, etc.
    <p>The look and feels supported are Metal, Window and Motif.  Each look and feel
    puts the OK and Cancel buttons in different locations and unfortunately the JFileChooser
    doesn't provide direct access to them.  Thus, for each look-and-feel the buttons must
    be found.
    <p>The following are known issues:  Rescanning doesn't work when in Motif L&F.  Some
    L&Fs have components that don't become available until the user clicks a button.  For
    example, the Metal L&F has a JTable but only when viewing in details mode.  The double
    click to choose a file does not work in details mode.  There are probably more unknown
    issues, but the changes made so far should make the JFileChooser easier to use.
    public class FileChooserFixer implements ActionListener, KeyListener, MouseListener, Runnable {
         Had to make new buttons because when the original buttons are clicked
         they revert back to the original label text.  I.e. some programmer decided
         it would be a good idea to set the button text during an actionPerformed
         method.
         private JFileChooser fileChooser = null;
         private JButton okButton = new JButton("OK");
         private JButton cancelButton = new JButton("Cancel");
         private JList fileList = null;
         private JTextField filenameTextField = null;
         private ActionListener actionListener = null;
         private long rescanTime = 20000;
         public FileChooserFixer(JFileChooser fc, ActionListener a) {
              fileChooser = fc;
              actionListener = a;
              fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
              okButton.setMnemonic('O');
              cancelButton.setMnemonic('C');
              JButton oldOKButton = null;
              JButton oldCancelButton = null;
              JTextField[] textField = getTextFields(fc);
              JButton[] button = getButtons(fc);
              JList[] list = getLists(fc);
              String laf = javax.swing.UIManager.getLookAndFeel().getClass().getName();
              if (laf.equals("javax.swing.plaf.metal.MetalLookAndFeel")) {
                   oldOKButton = button[0];
                   oldCancelButton = button[1];
                   filenameTextField = textField[0];
                   fileList = list[0];
              else if (laf.equals("com.sun.java.swing.plaf.windows.WindowsLookAndFeel")) {
                   oldOKButton = button[0];
                   oldCancelButton = button[1];
                   filenameTextField = textField[0];
                   fileList = list[0];
              else if (laf.equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel")) {
                   oldOKButton = button[0];
                   oldCancelButton = button[2];
                   button[1].setVisible(false); // hides the do-nothing 'Update' button
                   button[3].setVisible(false); // hides the disabled 'Help' button
                   filenameTextField = textField[1];
                   fileList = list[0];
              fix(oldOKButton, okButton);
              fix(oldCancelButton, cancelButton);
              okButton.addActionListener(this);
              cancelButton.addActionListener(this);
              fileList.addMouseListener(this);
              addKeyListeners(fileChooser);
              new Thread(this).start(); // note: rescanning in Motif feel doesn't work
         public void run() {
              try {
                   while (true) {
                        Thread.sleep(rescanTime);
                        Window w = SwingUtilities.windowForComponent(fileChooser);
                        if (w != null && w.isVisible())
                             fileChooser.rescanCurrentDirectory();
              } catch (Throwable err) {}
         public long getRescanTime() {
              return rescanTime;
         public void setRescanTime(long t) {
              if (t < 200)
                   throw new IllegalArgumentException("Rescan time >= 200 required.");
              rescanTime = t;
         private void addKeyListeners(Container c) {
              for (int i = 0; i < c.getComponentCount(); i++) {
                   Component d = c.getComponent(i);
                   if (d instanceof Container)
                        addKeyListeners((Container) d);
                   d.addKeyListener(this);
         private static void fix(JButton oldButton, JButton newButton) {
              int index = getIndex(oldButton);
              Container c = oldButton.getParent();
              c.remove(index);
              c.add(newButton, index);
              newButton.setPreferredSize(oldButton.getPreferredSize());
              newButton.setMinimumSize(oldButton.getMinimumSize());
              newButton.setMaximumSize(oldButton.getMaximumSize());
         private static int getIndex(Component c) {
              Container p = c.getParent();
              for (int i = 0; i < p.getComponentCount(); i++) {
                   if (p.getComponent(i) == c)
                        return i;
              return -1;
         public JButton getOKButton() {
              return okButton;
         public JButton getCancelButton() {
              return cancelButton;
         public JList getFileList() {
              return fileList;
         public JTextField getFilenameTextField() {
              return     filenameTextField;
         public JFileChooser getFileChooser() {
              return fileChooser;
         protected JButton[] getButtons(JFileChooser fc) {
              Vector v = new Vector();
              Stack s = new Stack();
              s.push(fc);
              while (!s.isEmpty()) {
                   Component c = (Component) s.pop();
                   if (c instanceof Container) {
                        Container d = (Container) c;
                        for (int i = 0; i < d.getComponentCount(); i++) {
                             if (d.getComponent(i) instanceof JButton)
                                  v.add(d.getComponent(i));
                             else
                                  s.push(d.getComponent(i));
              JButton[] arr = new JButton[v.size()];
              for (int i = 0; i < arr.length; i++)
                   arr[i] = (JButton) v.get(i);
              return arr;
         protected JTextField[] getTextFields(JFileChooser fc) {
              Vector v = new Vector();
              Stack s = new Stack();
              s.push(fc);
              while (!s.isEmpty()) {
                   Component c = (Component) s.pop();
                   if (c instanceof Container) {
                        Container d = (Container) c;
                        for (int i = 0; i < d.getComponentCount(); i++) {
                             if (d.getComponent(i) instanceof JTextField)
                                  v.add(d.getComponent(i));
                             else
                                  s.push(d.getComponent(i));
              JTextField[] arr = new JTextField[v.size()];
              for (int i = 0; i < arr.length; i++)
                   arr[i] = (JTextField) v.get(i);
              return arr;
         protected JList[] getLists(JFileChooser fc) {
              Vector v = new Vector();
              Stack s = new Stack();
              s.push(fc);
              while (!s.isEmpty()) {
                   Component c = (Component) s.pop();
                   if (c instanceof Container) {
                        Container d = (Container) c;
                        for (int i = 0; i < d.getComponentCount(); i++) {
                             if (d.getComponent(i) instanceof JList)
                                  v.add(d.getComponent(i));
                             else
                                  s.push(d.getComponent(i));
              JList[] arr = new JList[v.size()];
              for (int i = 0; i < arr.length; i++)
                   arr[i] = (JList) v.get(i);
              return arr;
         public File[] getSelectedFiles() {
              File[] f = fileChooser.getSelectedFiles();
              if (f.length == 0) {
                   File file = fileChooser.getSelectedFile();
                   if (file != null)
                        f = new File[] { file };
              return f;
         public void mousePressed(MouseEvent evt) {
              Object src = evt.getSource();
              if (src == fileList) {
                   if (evt.getModifiers() != InputEvent.BUTTON1_MASK) return;
                   int index = fileList.locationToIndex(evt.getPoint());
                   if (index < 0) return;
                   fileList.setSelectedIndex(index);
                   File[] arr = getSelectedFiles();
                   if (evt.getClickCount() == 2 && arr.length == 1 && arr[0].isFile())
                        actionPerformed(new ActionEvent(okButton, 0, okButton.getActionCommand()));
         public void mouseReleased(MouseEvent evt) {}
         public void mouseClicked(MouseEvent evt) {}
         public void mouseEntered(MouseEvent evt) {}
         public void mouseExited(MouseEvent evt) {}
         public void keyPressed(KeyEvent evt) {
              Object src = evt.getSource();
              int code = evt.getKeyCode();
              if (code == KeyEvent.VK_ESCAPE)
                   actionPerformed(new ActionEvent(cancelButton, 0, cancelButton.getActionCommand()));
              if (src == filenameTextField) {
                   if (code != KeyEvent.VK_ENTER) return;
                   fileList.getSelectionModel().clearSelection();
                   actionPerformed(new ActionEvent(okButton, 0, "enter"));
         public void keyReleased(KeyEvent evt) {}
         public void keyTyped(KeyEvent evt) {}
         public void actionPerformed(ActionEvent evt) {
              Object src = evt.getSource();
              if (src == cancelButton) {
                   if (actionListener != null)
                        actionListener.actionPerformed(evt);
              else if (src == okButton) {
                   File[] selectedFiles = getSelectedFiles();
                   Object obj = fileList.getSelectedValue(); // is null when no file is selected in the JList
                   String text = filenameTextField.getText().trim();
                   if (text.length() > 0 && (obj == null || selectedFiles.length == 0)) {
                        File d = fileChooser.getCurrentDirectory();
                        Vector vec = new Vector();
                        StringTokenizer st = new StringTokenizer(text, "\"");
                        while (st.hasMoreTokens()) {
                             String s = st.nextToken().trim();
                             if (s.length() == 0) continue;
                             File a = new File(s);
                             if (a.isAbsolute())
                                  vec.add(a);
                             else
                                  vec.add(new File(d, s));
                        File[] arr = new File[vec.size()];
                        for (int i = 0; i < arr.length; i++)
                             arr[i] = (File) vec.get(i);
                        selectedFiles = arr;
                   if (selectedFiles.length == 0) {
                        Toolkit.getDefaultToolkit().beep();
                        return;
                   if (selectedFiles.length == 1) {
                        File f = selectedFiles[0];
                        if (f.exists() && f.isDirectory() && text.length() > 0 && evt.getActionCommand().equals("enter")) {
                             fileChooser.setCurrentDirectory(f);
                             filenameTextField.setText("");
                             filenameTextField.requestFocus();
                             return;
                   boolean filesOnly = (fileChooser.getFileSelectionMode() == JFileChooser.FILES_ONLY);
                   boolean dirsOnly = (fileChooser.getFileSelectionMode() == JFileChooser.DIRECTORIES_ONLY);
                   if (filesOnly || dirsOnly) {
                        for (int i = 0; i < selectedFiles.length; i++) {
                             File f = selectedFiles;
                             if (filesOnly && f.isDirectory() || dirsOnly && f.isFile()) {
                                  Toolkit.getDefaultToolkit().beep();
                                  return;
                   fileChooser.setSelectedFiles(selectedFiles);
                   if (actionListener != null)
                        actionListener.actionPerformed(evt);

  • JFileChooser - unable to disable file extension display

    Hello All,
    I'm trying to use JFileChooser in my Swing application with following conditions:
    1) Only xml files will be displayed
    2) the file names shall NOT be shown with their extension. That is - listing of XML files shall occur only by their name - "abc" and not "abc.xml"
    I've already acheived the 1st objective.
    However, I am unable to block the display of file extension when JFileChooser opens.
    Has the display of file extension got to do with Operating System feature?
    Is there a way in Java Swings to curb such a a display?
    Thanks

    Implement your own FileView class (you can extend any of the L&F FileViews), then pass the object to:
    JFileChooser::setFileView(FileView fileView);
    Hint: The method you want to override is getName(File file).
    Regards,
    Marcin

  • Bug in JFileChooser (Java 1.6.0_03 running on Windows XP)?

    Hello All,
    I tried to display a JFileChooser dialog for file selection. It opens in the "My Documents" directory.
    This directory contained a big (400 megs) ZIP file.
    The JFileChooser dialog tooked a very long time to be displayed (I didn't selected this big zip file).
    If I remove the ZIP file, the JFIleChooser displays fast.
    I did the test with the JFileChooser demo from sun (http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html), and I find the same result.
    I think that's really a bug in the implementation of JFileChooser. Can you tell me if it is possible to let sun know this problem?
    Kind regards.
    Michael Hooreman

    JFileChooser has always had a problem with Windows XP's insistence on treating Zip files as folders. That's a stupid feature anyway, and I'm surprised JFileChooser doesn't automatically bypass it. You can disable the feature by running the following command: regsvr32 /u zipfldr Note that you'll be disabling the feature in Windows, not just in Java. You can re-enable it by running the same command without the /u.

  • Enhanced JFileChooser for file encoding selection

    In many I18N applications, files are stored in different encodings, including Unicode formats. It would be very useful for JFileChooser to have a file encoding selection mechanism similar to that in MS Windows' common file dialogs -- the "Encoding" box can be seen in Windows 2000/XP Notepad's File Open/Save dialog, directly under "File name" and "Save as type" combo boxes.
    This enhancement will make JFileChooser closely match Windows standard file dialogs and be a desirable option on other platforms as well.
    Vote for Bug Id 4935601:
    http://developer.java.sun.com/developer/bugParade/bugs/4935601.html
    (also posted in Internationalization Forum)

    That is a good point! I think all of documents encoded in Unicode need this feature to be saved correctly.

  • Softphone feature for Cisco Jabber Client

    Hello everyone,
    I have a CUCM cluster v.8.6.2 and a CUPS v.8.6.4. I've installed my full CUWL licenses as well as my CUP Licenses AND the Jabber for Everyone COP file. I've managed to install Jabber on Mac and on Windows and have all the features such as Chat, Desktop phone integration and Visual Voicemail with Cisco Unity Connection working as well. The only feature I'm having a huge hassle getting to work is the Softphone feature. I've tried adding a CUPC device with the user (btw everything is integrated and uses LDAP for authentication) as the digest account for it as well as the Owner ID. I've tried adding a CSF device as well (I remember reading it somewhere) but the Jabber client never discovers a Softphone device and all of the options on the client are grayed out for me to put in the device settings. I thought I saw it once looking for a device name CSFACILLI (ACILLI being my username) in the System Diagnostics for the Jabber for Mac client but now it just shows:
       Soft Phone Server
    Server Address:           cucm02.mycompany.net
    Server Port:                     2748
    Server Protocol:           --
    Device:                               --
    Line ID:                               --
    Status:                               Disconnected
    Any help or thoughts on this would be greatly appreciated! Thanks!
    Tony

    Aaron,
    Here's the bit I found interesting from the reporting function:
    -- 2012-07-25 08:31:01.000 DEBUG [0xacab02c0] -  CCUCMClient::downloadConfig -- begin:
    -- 2012-07-25 08:31:01.000 DEBUG [0xacab02c0] -  CCUCMClient::getCnfFile -- begin: , strDeviceName.c_str()=CSFacill, bHttp=FALSE
    -- 2012-07-25 08:31:01.000 DEBUG [0xacab02c0] -  CTFTPClient::Get -- begin: , remotefile=CTLFile.tlv, host=cucm02.mycompany.net, bIsAsyMode=TRUE, port=69
    -- 2012-07-25 08:31:01.000 DEBUG [0xb038d000] -  TFTP_Error Select error
    -- 2012-07-25 08:31:01.000 DEBUG [0xb038d000] -  TFTP_Error Can't get packet, retrycount=3
    -- 2012-07-25 08:31:01.000 DEBUG [0xb038d000] -   CTFTPClient::ContinueGet -- end!
    -- 2012-07-25 08:31:01.000 DEBUG [0xacab02c0] -  CTFTPClient::Get -- end!
    -- 2012-07-25 08:31:01.000 DEBUG [0xb038d000] -  CTFTPClient::ReceiveData -- end!
    -- 2012-07-25 08:31:01.000 DEBUG [0xacab02c0] -  CCUCMClient::getCnfFile -- end!
    -- 2012-07-25 08:31:01.000 DEBUG [0xacab02c0] -  CCUCMClient::downloadConfig -- end!
    -- 2012-07-25 08:31:01.000 DEBUG [0xacab02c0] -  CPhone::setPhoneMode -- end!
    -- 2012-07-25 08:31:01.000 DEBUG [0xb030b000] -  CTFTPClient::ReceiveData -- begin: , nCookie=5, bIsAsyMode=TRUE
    It looks like it's trying to get CTLFile.tlv from my TFTP servers (which are my subscribers). I went under TFTP File Management under OS Administration on the Subscribers and no such file exists. Is this something I have to download from Cisco? It does look like it's trying for the correct device, just can't get the Configuration File it needs... Your thoughts?
    Thanks,
    Tony

  • HT1925 I get a message saying The feature I am trying to use is on a network resource that is unavalable when I try to open iTunes.

    When I try to open iTunes a widow appears called Windows Installer.  It tells me that the feature you are trying to use is on a network resource that is unavalable.  It tell me to Click OK or try again or enter an alternative path to a folder containing the intallation package iTunes.msi.  I suggests I should find this in a drop down box in the window.  There is a box but no folder iTunes.msi.  If I click the cancel button iTunes will open and work. I wish to uninstall iTunes and then reinstall it.  I am finding that I can play music on iTunes OK through my sound card but if I try to play streamed music from the web in YouTube and fom My Space the music is a poor quality with crackles and distortion. Other forums suggest uninstalling iTunes and then re-installing it.  I ahve tried to uninstall iTunes but it comes up with the Window noted above and then stops.  I need to stop the crackle when streaming music. Please help.

    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • SmartWebPrinting.msi feature I am trying to use is on a network that is unavailable how do i fix it?

    I have bee having problems with SmartWebPrinting.msi it keeps loading up everytime i try to get on the internet or open one of my programs on my computer these are the mesges I am recieving from it: 1. the feature you are trying to use is on a network resource that is unavailable. 2. Enter an alternate path to a folder containing the instalation package 'SmartWebPrinting.msi in the box below. 3. An installation package for the product SmartWebPrinting.msi cannot be found try the installation again using a valid copy of the installation package SmartWebPrinting. msi. I am unable to load a web page correct and pages are missing and I cannot view web pages. and it wont go away and i put in the cd and it still keeps saying the same thing What do I do?
    Thank you

    Hi there,
    Try uninstalling Smart Web Printing using the instructions in this document:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c01812475&cc=us&dlc=en&lc=en
    1.  Expand the + sign next to:  How do I upgrade from HP Smart Web Printing to HP Smart Print
    2.  Follow the steps under:  Step one: Uninstall HP Smart Web Printing software (and then expand the + sign next to the operating system you are using)
    You can then install HP Smart Print (which has the same features as Smart Web Printing) if you have a need for this software (following the instructions in this document).
    Thanks!
    Tara
    **Although I am an HP employee, I am speaking for myself and not for HP.

Maybe you are looking for