Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | "Dr.UgoGagliardelli" <do.not.spam@me.please> |
| Newsgroups | it.comp.java |
| Subject | Re: array e focuslost |
| Date | Thu, 1 Oct 2015 15:24:42 +0200 |
| Organization | Aioe.org NNTP Server |
| Lines | 39 |
| Message-ID | <mujc6m$cqn$1@speranza.aioe.org> (permalink) |
| References | <muis23$11s$1@speranza.aioe.org> |
| NNTP-Posting-Host | ROWno1ty/XtM2o5XYGAqEA.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-15; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | csiph.com it.comp.java:8563 |
Show key headers only | View raw
Il 01.10.2015 10.46, Gulp® ha scritto:
> Ho un array di JTextField
> txtQuantita=new JTextField[]{txtQuantita0,txtQuantita1,txtQuantita2....
>
> non so come fare riferimento a tutti gli elementi dell'array con un unico:
>
> private void NomeArrayFocusLost(java.awt.event.FocusEvent evt)
>
> private void txtQuantitaFocusLost(..
>
> Non va bene. Come devo fare?
>
Sinceramente non ho capito.
La cosa certa e' che i JTextField sono accessibii sia tramite ogni
singola istanza (txtQuantita0,txtQuantita1 etc.) che tramite gli
elementi dell'array:
for(JTextField field: txtQuantita) {
...
}
oppure:
for(int i = 0; i < txtQuantita.length; i++) {
JTextField field = txtQuantita[i];
...
}
Ma probabilmenti avresti bisogno di una Collection, ad esempio:
List<JTextField> txtQuantita=
Arrays.asList(new JTextField[]
{txtQuantita0,txtQuantita1,txtQuantita2....});
in modo che:
private void NomeArrayFocusLost(java.awt.event.FocusEvent evt) {
if (txtQuantita.contains(evt.getSource)) {
... e' uno dei miei
}
}
Ma, ripeto, non ho capito quale sia il tuo obiettivo.
Back to it.comp.java | Previous | Next — Previous in thread | Find similar
array e focuslost Gulp® <gulp@hotmail.it> - 2015-10-01 10:46 +0200 Re: array e focuslost "Dr.UgoGagliardelli" <do.not.spam@me.please> - 2015-10-01 15:24 +0200
csiph-web