PDA

View Full Version : How do I add padding to various panels, widgets etc.



cdasher
24 Apr 2008, 5:14 AM
I have a FormPanel with a FlowLayout and when I add Fields to it, they are all backed up to the very edge (left side) of the panel, is there any way to add some padding or margins around the inside of the Form or a ContentPanel so that I have some space?

baluba
24 Apr 2008, 5:54 AM
The formpanel uses a AnchorLayout by default, not a flowpanel. Changing its layout will probably not work very well.

If you need to add buffer between the FormPanel's boundary and its child widgets there is no way of doing I think, I also tried earlier.

You can try the following as a workaround:

- Create a wrapping Container and set FillLayout(someValue) to establish the buffer. Turn borders on for wrapper.
- Create the FormPanel and disable the header, frame, and boundary and add it to the wrapper. Now it will look like the wrapper border is the form border.

Problem with this approach is that your wrapper needs to be sized explicitly. If the wrapper is sized by its parent, your panel will follow.

darrellmeyer
24 Apr 2008, 7:06 AM
Try this:

panel.setStyleAttribute("padding", "20");
This is what the FormPanel page in the explorer demo does.

cdasher
24 Apr 2008, 7:25 AM
Yes that worked the only problem is that the background for that is a light blue (it is inside a Window) and when I set the window background property to white it is still blue so I have the padding which is now a light blue. Also are the various style attributes documented so I can attempt to find my own answer before taking up your and others' time?

cdasher
24 Apr 2008, 7:28 AM
And once I fixed my button problem (a different post) I realized that the buttons are on the Form which is a light blue with the fields in a white box. So I guess I actually do not have an issue after all thanks.