Re: alphabetically arranging combobox entries

From: Stefan Waldmann (stefan.k.waldmann_at_vr-web.de)
Date: 06/24/04


Date: Thu, 24 Jun 2004 11:21:34 +0200

V S Rawat wrote:
> In my code (given below), I am getting the list of files
> with a particular extension, and adding their filename
> (wihtout extension) to a JCombobox.
>
> It is working but the combobox entries are not appearing
> alphabetically sorted.
>
> Is it possible to pick the filenames in sorted order, or to
> make them appear alphabetically in the combobox?
>
> In what order is it getting the list of files from dos (in
> win98SE)? createdOn? lastModified, lastAccessed? or what?
>
> Is there dos/window utility which can arrange files in that
> physical order in a folder? There was some norton utility I
> had accessed ages ago that was able to do this.

Hi,

I wouldn't rely on OS functions. (Who wants to be platform dependent? ;-)
Just do the sorting yourself in your application.

Collect your file names in an Array or List first, and sort them using
Arrays.sort(...) or Collections.sort(...) before you add them to your
combobox.

HTH

Regards,
Stefan



Relevant Pages

  • Re: Common Dialog - Change file extension
    ... VB's dialog (in fact no common dialog) provides this ... In order to change the extension you have to: ... - send a message to the control to extract the current text in the filename ... the 'Save as type' combobox in the Common Dialog Control. ...
    (microsoft.public.vb.general.discussion)
  • Re: Using an Excel sheet for batch delete
    ... but wondered what the routine would make of the situation where the input to both source and destination popups was identical. ... When I used it on filenames with no extension, ... Does the filename contain any dots. ... If SourcePath = "" Then Exit Sub ...
    (microsoft.public.excel.worksheet.functions)
  • Re: additional periods in file names
    ... A filename can have no more than one extension. ... Outlook Express, for example, shows only the first 20 or so characters of ... Microsoft Windows MVP ...
    (microsoft.public.windowsxp.general)
  • Re: Apply LEN result to string?
    ... If the end result is to strip the extension off a filename then you could do ... Public Function RemoveExtension(ByVal FileName As String, ... Using VB to fetch the filename and placing it in cell B1., ...
    (microsoft.public.excel.programming)
  • Re: Cant copy/paste
    ... MS-MVP Windows Shell/User ... I have these five Nvidia entries disabled. ... Filename: C:\WINDOWS\System32\nvshell.dll ... Extension Name: Desktop Explorer Menu ...
    (microsoft.public.windowsxp.help_and_support)