I need to make a component transparent, so there's nothing to see, but it still takes its place (unlike with setVisible(false)
).
With CSS terminology, I need visibility:hidden
rather than display:none
.
Ideally, it should work for any component, including containers and their children. So I don't think, subclassing and overriding paint
or alike is the way to go.
setVisible()
hides a component while it still occupies its space unlike setHidden()
which shrinks the component away`. See:
Form hi = new Form("Visible", BoxLayout.y());
Button r1 = new Button("Regular");
Button invisible = new Button("Invisible");
invisible.setVisible(false);
Button r2 = new Button("Regular");
Button r3 = new Button("Regular");
Button hidden = new Button("Hidden");
hidden.setHidden(true);
Button r4 = new Button("Regular");
hi.add(BoxLayout.encloseX(r1, invisible, r2));
hi.add(BoxLayout.encloseX(r3, hidden, r4));
hi.show();