Visibility of Buttons

Hello,

In my application there is a table, above it there are four buttons : edit, save, cancel, print.

I want when the application start only “Edit” and “Print” buttons to be visible and when you press “Edit”- only “Save” and “Cancel” to be visible.
At the moment when i start the application all of the buttons are visible. When I use one time “Edit” button, it works in the way I want. How I can make it work from the beginning?

Parts of the code:
The Layout

hLayout.addComponents( edit,save,cancel,print); The editing method:

 protected void configureEditable(boolean editable) {
                    
            treeTable.setEditable(editable);
            save.setVisible(editable);
            cancel.setVisible(editable);
            print.setVisible(!editable);
            edit.setVisible(!editable);
            treeTable.setSelectable(!editable);
                     
            if (editable && !fields.isEmpty()) {
              fields.get(0).focus();
            }
            
                }

Thank you!
BR,
Elena

Hi Elena,

what about setting the visibility when you create the buttons.

@Override
protected void init( VaadinRequest request) {
    edit = new Button("edit");
    edit.setVisible(true);
    cancel = new Button("cancel");
    cancel.setVisible(false);

    hLayout.addComponents( edit,cancel);
}

Thank you Dennis :slight_smile:
Now it works perfectly !

BR,
Elena