Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sounds like your design might need to be looked at. A few suggestions:</p> <ul> <li>Add the init method to your enum. So then you can iterate around the array of your enums and call the init method on it, so the enum knows how to do its own initialization </li> <li>create a Command object which does the initialization and create a Map of your enum as the key and the Command as the value. Cycle round the map running the Command for each enum.</li> <li>Use reflection - cost wise I wouldn't be too concerned for this, unless your system is after incredibly low latency</li> </ul> <p>For the first bullet, you could change the TextBox to hold a Field type against it e.g.</p> <pre><code>TextBox A = new TextBox(Field.A); TextBox B = new TextBox(Field.B); </code></pre> <p>So if TextBox knows it is A,B,C,D,E then you just need to loop around your Field[] and when it finds its mathing TextBox run the init code (which can be stored against the specific enum instance). Of course you will need to register all your TextBox instances in a data structure somewhere, as you seem very set against using the very widely used reflection API.</p> <p>In essence there has to be a link between the Field and the TextBox. Java cannot read your mind and know this without you telling it. Well, at least until Google unveil their telepathy API (and that would probably only be for Go...). This can be done based on naming (reflection), hardcoded logic (ifs or switches) or based on state. For the latter this means associating the Field with the TextBox, as I have demonstrated with the Constructor example above. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload