Hi,
I'd like to hide a JTextField from the GUI so that the layout doesn't
"see it" anymore ? I tried, setVisible(false) but it leaves an empty
space on the layout as if the component was still there.
Is there an easy way to achieve this ?
JGG
RedGrittyBrick - 29 May 2008 09:32 GMT
> Hi,
>
[quoted text clipped - 3 lines]
>
> Is there an easy way to achieve this ?
Use a different layout manager. Some layout managers will collapse
invisible components.
Have you tried resetting the components minimum,maximum,preferred sizes?
Have you called the container's pack()?
Which layout manager are you using?
Have you read http://sscce.org/ ?

Signature
RGB
Knute Johnson - 29 May 2008 17:45 GMT
> Hi,
>
[quoted text clipped - 5 lines]
>
> JGG
Just remove it.

Signature
Knute Johnson
email s/knute/nospam/
jgricourt@free.fr - 30 May 2008 14:58 GMT
I was using the layout called "TableLayout", which is a smart
replacement for swing gridbaglayout by the way. I found out that
calling layout.setRow(rowNum, 0) can make the components on the row
really invisible (it collapses the entire row). Problem solved !
Roedy Green - 31 May 2008 08:51 GMT
>I'd like to hide a JTextField from the GUI so that the layout doesn't
>"see it" anymore ? I tried, setVisible(false) but it leaves an empty
>space on the layout as if the component was still there.
see http://mindprod.com/jgloss/setvisible.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
jgricourt@free.fr - 31 May 2008 09:53 GMT
Yes, this describes exactly what happen with my layout manager.
TablLayout goes for the first solution by default but let the
programmer choose to go for the second one.
-- quote
How are invisible elements treated?
1. Do they act as if they weren’t there at all? Do the other
elements move in to take over the vacated space? Is the visual effect
the same as removing them from the enclosing Container?
2. Is there just a blank hole marking their place?
It depends on the LayoutManager you choose. LayoutManagers are free to
choose either strategy.