Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

File Explorer in Java

175 views
Skip to first unread message

Chaitanya

unread,
May 26, 2010, 8:11:47 PM5/26/10
to
Hi Java Gurus,

I need to implement a File Explorer that looks and works like the
native OS Explorer using Java.

I have looked at both Swing and SWT/JFace, and decided to go for Swing
as my code is going to run as an applet and I want platform
independence.

As I am looking for mimicking the default explorer look and feel, I
have to arrange icons in a grid fashion using Swing. How do I do this?
Do I get the list of files, get icons for them and then populate my
JPanel, item by item?

Is there a simpler/more direct way of doing this?

Thanks,
Chaitanya.

Jeff Higgins

unread,
May 26, 2010, 9:56:47 PM5/26/10
to
On 5/26/2010 8:11 PM, Chaitanya wrote:
> Hi Java Gurus,
>
> I need to implement a File Explorer that looks and works like the
> native OS Explorer using Java.
>
> I have looked at both Swing and SWT/JFace, and decided to go for Swing
> as my code is going to run as an applet and I want platform
> independence.
>
> As I am looking for mimicking the default explorer look and feel, I
> have to arrange icons in a grid fashion using Swing. How do I do this?
> Do I get the list of files, get icons for them and then populate my
> JPanel, item by item?

I'd populate the model and then create a view on the model.


>
> Is there a simpler/more direct way of doing this?

It sounds like a fairly complex project.
>
> Thanks,
> Chaitanya.

John B. Matthews

unread,
May 26, 2010, 10:42:00 PM5/26/10
to
In article <htkjho$n2t$1...@news.eternal-september.org>,
Jeff Higgins <oohi...@yahoo.com> wrote:

> On 5/26/2010 8:11 PM, Chaitanya wrote:
> > Hi Java Gurus,
> >
> > I need to implement a File Explorer that looks and works like the
> > native OS Explorer using Java.
> >
> > I have looked at both Swing and SWT/JFace, and decided to go for Swing
> > as my code is going to run as an applet and I want platform
> > independence.
> >
> > As I am looking for mimicking the default explorer look and feel, I
> > have to arrange icons in a grid fashion using Swing. How do I do this?

Chaitanya: Here's an example using BoxLayout; see genWestPanel():

<http://robotchase.svn.sourceforge.net/viewvc/robotchase/trunk/src/org/gcs/robot/RCHelp.java?revision=63&view=markup>

> > Do I get the list of files, get icons for them and then populate my
> > JPanel, item by item?
>
> I'd populate the model and then create a view on the model.

Chaitanya: Good advice. The example in NetBeans' Outline API
illustrates this model-view approach:

<http://bits.netbeans.org/dev/javadoc/org-netbeans-swing-outline/org/netbeans/swing/outline/Outline.html>

> > Is there a simpler/more direct way of doing this?
>
> It sounds like a fairly complex project.

Yes, especially while maintaining platform independence.

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>

Daniel Pitts

unread,
May 27, 2010, 1:58:32 PM5/27/10
to
If what you really want is to have a file choose, check out JFileChooser.

If you truly want an "explorer" style window, then you'll have to target
several platforms. Unix/Linux have a few, just to start with. Windows
has several different kinds, depending on the version (XP is different
than NT, Vista is different still). Mac OSX also has a different style.

So, do you *really* need it to L&F like the Native OS explorer, or is
that just a "nice-to-have"?

Personally, I think it would be better to look at it from functional
requirements. What do you want the user to be able to do? Be more
specifically than "everything they can in Explorer." Once you have those
requirements nailed down, then try to decide what the best UI experience
is for the User.

*Then*, figure out how to implement it.


--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

John B. Matthews

unread,
May 27, 2010, 10:55:33 PM5/27/10
to

Ian Shef

unread,
Jun 1, 2010, 3:29:18 PM6/1/10
to
Chaitanya <csp...@gmail.com> wrote in news:ef772aba-4f2b-442b-9197-
5130b2...@z13g2000prh.googlegroups.com:

> Hi Java Gurus,
>
> I need to implement a File Explorer that looks and works like the
> native OS Explorer using Java.
>
> I have looked at both Swing and SWT/JFace, and decided to go for Swing
> as my code is going to run as an applet and I want platform
> independence.
>

[snip]

Due to applet security restrictions, this is unlikely to work well unless:

- The applet is loaded from the local file system (in which case, why an
applet and not an application?), OR
- The applet is signed, OR
- JNLP is used (which may impose its own limitations).


Also, I am confused about the reference to "looks ... like native OS
Explorer" in combination with "I want platform independence".


Andrew Thompson

unread,
Jun 3, 2010, 11:04:12 PM6/3/10
to
On Jun 2, 5:29 am, Ian Shef <inva...@avoiding.spam> wrote:
> Chaitanya <cspi...@gmail.com> wrote in news:ef772aba-4f2b-442b-9197-
> 5130b2156...@z13g2000prh.googlegroups.com:

>
> > Hi Java Gurus,
>
> > I need to implement a File Explorer that looks and works like the
> > native OS Explorer using Java.
>
> > I have looked at both Swing and SWT/JFace, and decided to go for Swing
> > as my code is going to run as an applet and I want platform
> > independence.
>
> [snip]
>
> Due to applet security restrictions, this is unlikely to work well unless:
>
> - The applet is loaded from the local file system ..

Older versions of AppletViewer did not impose a
security sand-box, whereas later versions do. IDEs
have a way of side-stepping that and launching AV
with no security.

> - The applet is signed, OR
> - JNLP is used (which may impose its own limitations).

Same basic sand-box as for an embedded applet.

The JNLP API also provides ways for a sand-boxed
app. to access the local file-system, but they
would be entirely inadequate for a file explorer.
E.G. The JNLP API 'equivalent' of a File is a
FileContents. The FC will not provide the path
to the file.
<http://java.sun.com/j2se/1.5.0/docs/guide/javaws/jnlp/javax/jnlp/
FileContents.html>

--
Andrew T.
pscode.org

Ian Shef

unread,
Jun 4, 2010, 3:26:08 PM6/4/10
to
Andrew Thompson <andrew...@gmail.com> wrote in news:2f1245b3-7738-452f-
bf27-a2a...@a2g2000prd.googlegroups.com:

> On Jun 2, 5:29�am, Ian Shef <inva...@avoiding.spam> wrote:
>> Chaitanya <cspi...@gmail.com> wrote in news:ef772aba-4f2b-442b-9197-
>> 5130b2156...@z13g2000prh.googlegroups.com:
>>
>> > Hi Java Gurus,
>>
>> > I need to implement a File Explorer that looks and works like the
>> > native OS Explorer using Java.
>>
>> > I have looked at both Swing and SWT/JFace, and decided to go for Swing
>> > as my code is going to run as an applet and I want platform
>> > independence.
>>
>> [snip]
>>
>> Due to applet security restrictions, this is unlikely to work well
unless
>:
>>
>> - The applet is loaded from the local file system ..
>
> Older versions of AppletViewer did not impose a
> security sand-box, whereas later versions do. IDEs
> have a way of side-stepping that and launching AV
> with no security.
>
>> - The applet is signed, OR
>> - JNLP is used (which may impose its own limitations).
>
> Same basic sand-box as for an embedded applet.
>
> The JNLP API also provides ways for a sand-boxed
> app. to access the local file-system, but they
> would be entirely inadequate for a file explorer.

<snip>
Thanks for the additional detail. You are tending to confirm my suspicion
that Chaitanya should be implementing an application and not an applet. To
use an applet as a file explorer, Chaitanya will need to

- Deal with applet signing, OR
- Ensure that an older version of AppletViewer is available, OR
- Write an AppletViewer application (in which case, why not just make the
file explorer an application), OR
- Use from an IDE

Talking to myself...

I still don't understand Chaitanya's statements "looks and works like the
native OS" versus "I want platform independence".

I don't even know what "looks ... like the native OS" means when I think
about the various file explorers available for Linux. I am confused.

If Chaitanya wants a file explorer that "looks and works like the native
OS", why not just use org.jdesktop.jdic.desktop.Desktop#open(java.io.File)
and be done with it?


Andrew Thompson

unread,
Jun 5, 2010, 3:16:05 AM6/5/10
to
On Jun 5, 5:26 am, Ian Shef <inva...@avoiding.spam> wrote:
>..If Chaitanya wants a file explorer that "looks and works like the native

> OS", why not just use org.jdesktop.jdic.desktop.Desktop#open(java.io.File)
> and be done with it?

++

--
Andrew T.
pscode.org

0 new messages