🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #9060

Re: Pressing a JFileChooser's buttons

#9060
From: James Cook
Date: Thu, 08 Jun 2000 00:00
33 lines
1794 bytes
It *is* a rat's nest!

You may want to just walk the component children map until you get to a JButton. I do this in my multifile opentool looking for the
JList.

Something like this may work:

    protected static void findAllJButtons(ArrayList list, JComponent comp, int indent) {
        // these two lines are just for debug output
        for (int j = indent; j >= 0; j--) System.out.print(" ");
        System.out.println(comp.getClass().getName());

        if (comp instanceof JButton) list.add(comp);
        if (comp instanceof JComponent) {
            JComponent jcomp = (JComponent)comp;
            for (int i = 0, c = jcomp.getComponentCount(); i < c; i++) {
                if (jcomp.getComponent(i) instanceof JComponent) {
                    findAllJButtons(list, (JComponent)jcomp.getComponent(i), indent + 2);
                }
            }
        }
    }

Pass it an empty ArrayList, the filechooser, and 0. It will return all of the JButtons in the list.

jim


Joi Ellis <joi@aravox.com> wrote in message news:393F0D36.EAF4580@aravox.com...
> I've mucked around for several hours and really don't know how to
> approach this.  JFileChooser is a rats nest!
>
> Any suggestions?
Technical Details
Message-ID: <8ho5ni$r0e7@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <393F0D36.EAF4580@aravox.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,f49abd9d7ca919ce
X-Google-Attributes: gid111d45,public
From: "James Cook" <jimcook.remove.for.spam@iname.com>
Subject: Re: Pressing a JFileChooser's buttons
Date: 2000/06/08
Message-ID: <8ho5ni$r0e7@bornews.borland.com>
X-Deja-AN: 632601337
References: <393F0D36.EAF4580@aravox.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.swing