salvin francis wrote:Hi Peter,
While you are searching for an answer, I would like to point out that jTextField1, jTextField2, etc. are not good variable names. You have written comments to understand them as "//Author"
Why cant you use authorTxt (or similar) instead of jTextField1 ? It would be less confusing.
Fred Kleinschmidt wrote:Why does your clear() method call setName("") on all of the components? This seems like a really dumb thing to do since all components now have the same null name.
Assuming you might have changed the background and when cleared need to reset the color, you could cut the code in half by creating functions like clearText(), clearLabel(), etc. For example:
then your clear() method just calls this method for each test field that needs to be cleared. You could also place all of the text fields in an array or ArrayList and use something like:
or even use the Java8 streaming feature to reduce that to one line.
Note also that you might have problems with component sizes when you alter the text, depending on the layout manager being used.
Campbell Ritchie wrote:None of your code shows any of the text components having the text cleared.
Fred Kleinschmidt wrote:Why does your clear() method call setName("") on all of the components? This seems like a really dumb thing to do since all components now have the same null name.