Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | "Dr.UgoGagliardelli" <do.not.spam@me.please> |
|---|---|
| Newsgroups | it.comp.java |
| Subject | Re: array e focuslost |
| Date | 2015-10-01 15:24 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mujc6m$cqn$1@speranza.aioe.org> (permalink) |
| References | <muis23$11s$1@speranza.aioe.org> |
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