Question

How can I set the insets to a Vaadin label.I have below developed.I want to have some space between the button and label.

        button_3 = new Button();
        button_3.setCaption("Button");
        button_3.setImmediate(true);
        button_3.setWidth("-1px");
        button_3.setHeight("-1px");
        horizontalLayout_4.addComponent(button_3);

        // prize_set_label
        prize_set_label = new Label();
        prize_set_label.setImmediate(false);
        prize_set_label.setWidth("-1px");
        prize_set_label.setHeight("-1px");
        prize_set_label.setValue("small:23");
        horizontalLayout_4.addComponent(prize_set_label);
Was it helpful?

Solution

To add spacing between components in (most) layouts, you can use setSpacing(boolean) - e.g. horizontalLayout_4.setSpacing(true);

If you want to change the size of the spacing, you must change this in CSS.

I don't understand what you are doing there with the size of the button & label; as far as I'm aware, setting the width/height to negative values is not valid in Vaadin.

OTHER TIPS

To some who want to modify a Component Insets (e.g. for a clean, readable CellEditor under some LaF (yes I'm looking at you Nimbus!)), the insets are actually the one from the Component Border, so you need to specify an empty border or just remove with it Component.setBorder(null).

N.B. that if no border is defined, it's the Component peer insets that are used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top