This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 136965 - fields become unexpectedly bottom anchored
Summary: fields become unexpectedly bottom anchored
Status: NEW
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-11 01:09 UTC by David Konecny
Modified: 2008-09-16 22:09 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Konecny 2008-06-11 01:09:01 UTC
How to reproduce:
* create a JPanel with Free Design
* add to left top corner (with default left and top space around) e.g. JLabel
* add JEditBox under JLabel with default align
* so far everything is Top anchored

Now, if you resize bottom of your JPanel so that there is *Default* space between JEditBox and bottom edge of JPanel
everything will be still OK. But if you rezie JPanel so that there is 0 space between JEditBox and bottom edge of JPanel
suddenly all components become Bottom anchored - try making panel bigger again and you will see that both JEditBox and
JLabel are attached to the bottom.

I can attach screenshot if needed. Consider increasing to P2 as it is really annoying and completelly destroys your
forms - you have to fix all anchoring. Thanks, -David
Comment 1 Jana Maleckova 2008-06-11 09:21:58 UTC
I don't think this could be P2 because there is simple workaround. Just invoke popup menu on JEditBox and set anchor
back to top. Then you can resize JPanel with no fear.

Another case, that anchoring of component is changed when JPanel is resized in way that there is no space between its
bottom edge and JEditBox, I leave for developer evaluation.
Comment 2 David Konecny 2008-06-11 11:10:29 UTC
Re. "simple workaround" - if you have a form with 20 items it is 20 items which you have to fix one by one. I'm not sure
whether I could select them all and fix them at once. It's very annoying as you may end up fixing one form several
times. Try it yourself: design JPanel with handful of components where components have 0 space from jpanel edges; once
you finish try to add one more field at the bottom; and later one more - each time your form gets screwed and you may
actually not even notice it. That's why I think it is P2.
Comment 3 Jana Maleckova 2008-06-11 21:27:53 UTC
|Re. "simple workaround" - if you have a form with 20 items it is 20 items which you have to fix one by one. I'm not sure
|whether I could select them all and fix them at once.

yes, you can. You can do multiselection in various ways like in inspector when you select nodes which represent
components in design (with help of ctrl or shift modifiers) or do it directly in design - just push left mouse button
and define area  with components which should be selected. Then you can set anchor for more components at once.

|once you finish try to add one more field at the bottom; and later one more - each time your form gets screwed
We should clarify the steps you have done
I tried to follow your description and the result seems to be different in my case

1. create jPanel
2. placed several components e.g. jButtons into horizontal row with default spaces between each other
3. resize bottom edge of jPanel that there is no space between buttons and jPanel's bottom edge
4. change anchor of buttons from bottom to top
5. insert another jButton in the row of Buttons
Is that correct ? 
Result in my case is that anchor of all buttons is not changed after step 5 and stayed anchored to top.Therefore jPanel
 can be resized without changing of buttons position. Anchor to top is not changed till you set space between bottom
edge of jPanel and jButtons again to zero. So I didn't notice that form was screwed

It seems you reached different results so, it would be better if you enclosed your form (form and java file) there with
proper description which leads to screwed form.
Comment 4 David Konecny 2008-06-11 22:50:45 UTC
It is not INCOMPLETE - you were able to reproduce the problem in step #3 right?

In step #5 instead of adding component horizontally add it vertically - add it under your horizontal row of components -
in order to do that I first make panel bigger; then add component and then make panel smaller again with no gap between
bottom edge and just added component -> result is you have to fix anchor again.
Comment 5 Jana Maleckova 2008-06-12 09:48:42 UTC
In my opinion, it is a feature that the anchor is changed in every case when you manually resize container and stick
it's  bottom edge on components with 0 space. The same behavior, you can encounter with right edge of jPanel. But the
question is if this is useful for user. It's better to wait for developer evaluation as I wrote at the beginning.

I just wanted to help you and give you fast and simple way how to set it back as you want
Comment 6 Jan Stola 2008-09-16 13:54:20 UTC
Let me explain the current behaviour. We do our best to make sure
that every form designed using Free Design is resizable. If there
are some resizable components then the resizability of the container
is defined by these components. If there are no-resizable components
in the given direction then we have to insert a resizable gap.
By default, the vertical resizable gap is placed at the bottom
of the container.

If you drag the bottom edge of the container and let it snap
at the bottom edge of some component then the algorithm believes
that you wan't to keep these edges together. Hence, it eliminates
the gap that was there before. Unfortunately, this gap was the
resizable one and we must make another gap resizable to make
sure that the container is resizable. That's how the gap at
the top becomes resizable and why the anchoring is changed.

While I understand that it can be painful in your case,
it works as it was designed (and it seems to be the right
algorithm in other case). So, I am changing this issue
to enhancement with the goal to reevaluate the meaning
of snapping of the bottom (or right) edge of the container
to some component.
Comment 7 David Konecny 2008-09-16 22:09:29 UTC
Thanks for the detailed explanation. You said that "...it seems to be the right algorithm in other case...". Could you
please give an example of some of these?

I would still argue that making top gap resizable is not what user want most of the time. The logic of UI layout (in
Western countries) is that things are laid out from top left corner. Why not just keep bottom gap resizable? Technically
it is not a problem, right? (changing anchor of all components to Top moves resizable gap back to bottom) It is just
your algorithm, right?