Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » How can SpringLayout code be made immutable?(Working on a SpringLayout with over 20 components all potentially interrelated, adding a 21st component can mess everything up.)
How can SpringLayout code be made immutable? [message #1799859] Sat, 15 December 2018 02:21 Go to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 142
Registered: March 2018
Senior Member
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

Re: How can SpringLayout code be made immutable? [message #1799861 is a reply to message #1799859] Sat, 15 December 2018 09:16 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 529
Registered: August 2014
Senior Member
You are barking up a wrong tree. This is off-topic for Eclipse.

The question of SpringLayout belongs to general Java questions about the AWT toolkit. Eclipse uses internally the SWT toolkit, which is different.

Try to find a general Java discussion forum for the questions. There is a tutorial on Oracle Java pages.


--

Tauno Voipio
Re: How can SpringLayout code be made immutable? [message #1799881 is a reply to message #1799861] Sun, 16 December 2018 16:38 Go to previous message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 142
Registered: March 2018
Senior Member
Sorry. I was trying to add this to the discussions regarding WindowBuilder. WindowBuilder is useful, but only to a certain extent, and people who try to use it may have problems because of the characteristics of WindowBuilder, not the characteristics of SpringLayout as presented by Oracle.
Previous Topic:Character input
Next Topic:How to Install Java Eclipse in Citrix Multiple User environment
Goto Forum:
  


Current Time: Wed Feb 26 05:09:42 GMT 2020

Powered by FUDForum. Page generated in 0.07262 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top