Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.java > #12852
| Path | csiph.com!news.swapon.de!newsreader4.netcologne.de!news.netcologne.de!.POSTED!not-for-mail |
|---|---|
| From | Patrick Roemer <sangamon@netcologne.de> |
| Newsgroups | de.comp.lang.java |
| Subject | Re: Java/NetBeans: Verwaltung von RadioButtons in einer ArrayList |
| Date | Sat, 24 Oct 2015 15:34:11 +0200 |
| Organization | news.netcologne.de |
| Lines | 45 |
| Distribution | world |
| Message-ID | <n0g1cj$fpi$1@newsreader4.netcologne.de> (permalink) |
| References | <phcm2bde5n30n847r75qdjjvh60jiik2ae@4ax.com> |
| NNTP-Posting-Host | xdsl-78-35-77-50.netcologne.de |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | newsreader4.netcologne.de 1445693651 16178 78.35.77.50 (24 Oct 2015 13:34:11 GMT) |
| X-Complaints-To | abuse@netcologne.de |
| NNTP-Posting-Date | Sat, 24 Oct 2015 13:34:11 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.24) Gecko/20100411 Thunderbird/2.0.0.24 Mnenhy/0.7.6.0 |
| X-Enigmail-Draft-Status | N1110 |
| In-Reply-To | <phcm2bde5n30n847r75qdjjvh60jiik2ae@4ax.com> |
| Xref | csiph.com de.comp.lang.java:12852 |
Show key headers only | View raw
Responding to Rainer:
> ich möchte eine große Zahl von RadioButtons in einer ArrayList
> verwalten, um diese mit Hilfe einer for-each-Schleife abfragen
> und/oder manipulieren zu können, also z. B.
>
> (1)
> ArrayList<javax.swing.JCheckBox> boxlist;
> boxlist = new ArrayList<>();
>
>
> (2)
> boxlist.add(chkEins);
> boxlist.add(chkZwei);
> boxlist.add(chkDrei);
> ...
>
> (3)
> for (javax.swing.JCheckBox box : boxlist) {
> if (box.isSelected()) {
> ....
> }
> }
>
>
> Wie kann ich auch (2) mit einer Schleife realisieren?
Bei einer "großen Zahl" will man die Dinger wahrscheinlich eh
ausschließlich in einer Liste ö.ä. verwalten - mit expliziten Feldern
chkZweitausendeinhundertdreiundneunzig & Co. zu hantieren, dürfte
umständlich werden.
int boxCount = ...;
for(int idx = 0; idx < boxCount; boxCount++) {
boxlist.add(new JCheckBox());
}
Je nachdem, was für eine Bedeutung/Funktion die Dinger haben und wie sie
in der UI angeordnet werden sollen, könnte sich vielleicht auch
anbieten, eine JTable mit entsprechendem Modell (BitSet?) zu nehmen und
als Renderer/Editor Checkboxes zu verwenden (das ist eh der Default für
Zellen vom Typ Boolean).
Viele Grüße,
Patrick
Back to de.comp.lang.java | Previous | Next — Previous in thread | Next in thread | Find similar
Java/NetBeans: Verwaltung von RadioButtons in einer ArrayList Rainer <Rainer.Poop@ObjectMail.com> - 2015-10-24 09:28 +0200
Re: Java/NetBeans: Verwaltung von RadioButtons in einer ArrayList Patrick Roemer <sangamon@netcologne.de> - 2015-10-24 15:34 +0200
Re: Java/NetBeans: Verwaltung von RadioButtons in einer ArrayList Rainer <Rainer.Poop@ObjectMail.com> - 2015-10-25 08:54 +0100
Re: Java/NetBeans: Verwaltung von RadioButtons in einer ArrayList Patrick Roemer <sangamon@netcologne.de> - 2015-10-25 18:34 +0100
Re: Java/NetBeans: Verwaltung von RadioButtons in einer ArrayList Marco Bakera <pintman@bakera.de> - 2015-10-26 14:02 +0100
csiph-web