|How can SpringLayout code be made immutable? [message #1799859]
||Sat, 15 December 2018 02:21
| Patrick Moran
Registered: March 2018
Some systems are rigid, e.g., a fine sports car. If you move the steering wheel a fraction of an inch from any given position, you get a determinate change in the direction the front wheels point in. In sports cars you do not want "slop."|
In a complex system with loose links between components, change a couple things in small ways and you will find that you cannot predict the outcome. This fact, according to General Paul Van Riper, is why planning and forecasts during wars is of very limited validity in time. The same goes for weather forecasts, which exhibit "chaos" phenomena.
The way SpringLayouts work is definitely on the chaotic side. If I have, say, five stacked JTextArea boxes stacked up, and I have put springs in so that they will all expand horizontally but will not expand vertically when the enclosing window is stretched, and everything is working perfectly, I can ruin things by deciding that I need to put one or more components (e.g., a label and a button) above them. Run the program with the new components in place, and some of the JTextAreas may begin to expand vertically and consequently start covering other components or causing other mischief.
A "spring" that was originally connected to the upper end of the enclosing window is now connected, e.g., to the bottom edge of a label. The label may have a spring between its lower edge and the lower edge of the enclosing window. so expanding the enclosing box "south," means that the lower edge of the label move downward, which in turn means that the upper edge of the JTextArea now moves down too, but since its lower edge was perhaps tied to the upper edge of the enclosing window, the JText Area shrinks down to nothing.
After much confusion, I finally learned that for every component that gets defined in terms of SpringLayouts coordinates, I need to make a copy of it in a comment box below it so that when the WindowBuilder changes the edges by which it is defined I can find out where things have gotten distorted.
If I then find I need to add another component somewhere, I can do so in WiondowBuilder, but then I immediately need to check the source code to see which lines of code the software may have completely rewritten, and get the right edges connected to each other again.
In the beginning it was very confusing to me because without comparing old versions with new versions line by line and word by word, it could appear that there were no significant changes except for the addition of the new GUI component.
The work-around would seem to be to put all the components down in their approximate positions while using WindowBuilder, and then only editing them in a regular editor, and checking changes made in spacing or whatever by running the program.
I've never seen anything definitive about what the little rim sliders on the outline rectangles "set top alignment," "set bottom alignment," and "make resizeable" actually do. To the extent they have any effect at all, they seem to make irreversible changes. I have decided not to use them at all, lacking any documentation of their intended use.
Any way to freeze individual springLayout units would be helpful.
[Updated on: Sat, 15 December 2018 07:28]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.07262 seconds