Search code examples
gwtbuttonlabelgxt

Add new labels on button listener GWT


I'm trying to add new labels to a panel and this is when a button is clicked, in fact the number of labels is unknowing because my application consists in extracting some informations from a file and then display each information in a label so i have to upload the file and then extract the informations, i created an uploadfile and i'm able to extract the informations but i face a problem to display each information in its label, i can't create many labels and then with label.settext() make each information in its label beacuase the number of labels/informations is variable.

So can you advice/help me so i can make this working.

Best regards.


Solution

  • If you get the result from an Array for example you can do like this:

    String[] data; //You can add you data here
    
    addButton.addClickHandler(new ClickHandler() {
    
            @Override
            public void onClick(ClickEvent event) {
                 for (String s : data) {
                          RootPanel.get().add(new Label(s));
                 }
            }
        });
    

    That way you can add as much Labels as you want