Results 1 to 13 of 13
  1. #1
    nwboy74 is offline Member
    Join Date
    Oct 2008
    Posts
    45
    Rep Power
    0

    Default Where are the components for a JFileChooser built?

    I need to create a watered-down version of a JFileChooser that will be populated with files from a remote filesystem. A server on the remote system will supply me with a list of files in a specified directory and then I'll display them on the client side. I've been trying to mimic a JFileChooser's layout, but I cannot figure out where the components are actually being built (buttons, panels, etc).

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,327
    Rep Power
    25

    Default

    where the components are actually being built
    Can you explain what "being built" means?
    Are you referring to what the layout manager does to position and size a component?

  3. #3
    nwboy74 is offline Member
    Join Date
    Oct 2008
    Posts
    45
    Rep Power
    0

    Default

    By built, I mean there are individual elements that make up the dialog: buttons, drop-down lists, area for the files to be listed, etc. Which class handles the construction of these individual elements and adds them to a container?

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,327
    Rep Power
    25

    Default

    Which class handles the construction of these individual elements and adds them to a container
    That would probably be your code if you're building a file chooser class.
    How much GUI programming experience do you have?

  5. #5
    nwboy74 is offline Member
    Join Date
    Oct 2008
    Posts
    45
    Rep Power
    0

    Default

    I've done GUI programming and I'm sure I could come up with something on my own, but it's tedious. I was hoping to just witness how JFileChooser is doing it and tailor to my own needs.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,327
    Rep Power
    25

    Default

    The source for most classes is included with the JDK.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,198
    Rep Power
    19

    Default

    Quote Originally Posted by nwboy74 View Post
    I need to create a watered-down version of a JFileChooser that will be populated with files from a remote filesystem. A server on the remote system will supply me with a list of files in a specified directory and then I'll display them on the client side.
    Looks like setting a custom FileSystemView may be enough for that.

    I've been trying to mimic a JFileChooser's layout, but I cannot figure out where the components are actually being built (buttons, panels, etc).
    IIRC you'll find that in the UI delegate code. But I really don't think you need to do that.

    db

  8. #8
    nwboy74 is offline Member
    Join Date
    Oct 2008
    Posts
    45
    Rep Power
    0

    Default

    I tried creating a custom FileSystemView, but since the file system is remote, I can't use java.io.Files because when it gets to my machine, those files don't exist. If someone tries clicking on a directory to drill down, I get all sorts of weird behavior. Or if they try to go up a directory...

  9. #9
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,327
    Rep Power
    25

    Default

    You need to override the File class with your own version of the class that provides what the user of the File class needs.

  10. #10
    nwboy74 is offline Member
    Join Date
    Oct 2008
    Posts
    45
    Rep Power
    0

    Default

    Thanks for your help in persuading me to subclass FileSystemView. Not sure what I did the first time, perhaps I didn't override enough methods, but I overwrote all public methods for FileSystemView and File and it appears to be working now. I'm still baffled as to how JFileChooser creates its various components (followed source code but never saw where it was creating buttons and lists etc).

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,198
    Rep Power
    19

    Default

    Quote Originally Posted by nwboy74 View Post
    Thanks for your help in persuading me to subclass FileSystemView. Not sure what I did the first time, perhaps I didn't override enough methods, but I overwrote all public methods for FileSystemView and File and it appears to be working now.
    Good to know.

    I'm still baffled as to how JFileChooser creates its various components (followed source code but never saw where it was creating buttons and lists etc).
    I already gave you a hint: look at BasicFileChooserUI

    db
    Last edited by DarrylBurke; 07-27-2010 at 09:57 AM. Reason: Fixed the quote tags

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Darryl.Burke View Post
    I already gave you a hint: look at BasicFileChooserUI
    The API of that class is of course again generously or more than adequately documented ;-)

    kind regards,

    Jos

  13. #13
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,198
    Rep Power
    19

    Default

    We're talking source code, not API documentation here, see #7. The components that make up a file chooser aren't required to be part of the programming interface.

    db

Similar Threads

  1. JMF: capturing built in webcam
    By Perre in forum Advanced Java
    Replies: 0
    Last Post: 02-20-2010, 10:58 AM
  2. Using Applets built in GreenFoot?
    By sciguy77 in forum New To Java
    Replies: 0
    Last Post: 01-19-2009, 08:43 PM
  3. print without built functions
    By j2vdk in forum New To Java
    Replies: 19
    Last Post: 12-28-2008, 05:22 PM
  4. Netbeans built .jar for Mac
    By zobelogne in forum NetBeans
    Replies: 2
    Last Post: 11-03-2008, 04:54 PM
  5. Using the built-in enumeration methods
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:35 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
  •