Piet Souris wrote:
But GUI builders are designed to use drag and resize with the mouse. Why don't you want to use that?
GUI Builders are not part of
Java. They are provided by specific IDEs/IDE plugins. There was, in fact, a very long drought period between the demise of Borland's Visual Café and the GUI builder later added to IntelliJ, which triggered addition of GUI builders to competitive IDEs.
While I see that this question was cross-filed under NetBeans, all of the discussions have been about Swing itself, irrespective of the
IDE used. And that's good because A) it doesn't encourage dependency on an IDE (the old IDE-as-a-crutch concern) and B) it means that answers are also of potential use to
everyone, not just NetBeans users.
Plus, we don't get punished by screenshots.
Rob's suggestion is noteworthy. It makes a best-effort attempt to size the control specifically to its potential contents. The "W" character is typically one of the widest in a font, so it - or "M" - are often used at reference metrics for worst-case computation of the amount of real estate required to display entered text.
Some people, when well-known sources tell them that fire will burn them, don't put their hands in the fire.
Some people, being skeptical, will put their hands in the fire, get burned, and learn not to put their hands in the fire.
And some people, believing that they know better than well-known sources, will claim it's a lie, put their hands in the fire, and continue to scream it's a lie even as their hands burn down to charred stumps.