Error while trying to change column widths from Tableview

Asked

Viewed 108 times

0

I have a method that increases and decreases the width of my table at the click of a button (it works perfectly):

public void toggleTela()
{

    if(this.tblAudiencias.getWidth() == 940)
    {
        this.toogleItens(true);
        this.tblAudiencias.setMinWidth(649);
        this.tblAudiencias.setLayoutX(287);
        this.btnToggle.setText("< Ocultar");

    }
    else
    {
        this.toogleItens(false);
        this.tblAudiencias.setMinWidth(940);
        this.tblAudiencias.setLayoutX(5);
        this.btnToggle.setText("> Mostrar");
    }
    this.redefineColunas(this.tblAudiencias.getWidth());

}

The method redefineColunas should define the width of the columns according to the table:

private void redefineColunas(double tabela)
{
    this.colAudiencia.setMinWidth(tabela * 0.20);
    this.colData.setMinWidth(tabela * 0.15);
    this.colHora.setMinWidth(tabela * 0.10);
    this.colAutor.setMinWidth(tabela * 0.20);
    this.colReu.setMinWidth(tabela * 0.15);
    this.colProcesso.setMinWidth(tabela * 0.20);
}

The goal was to give a few percentages for each column, when it enters the else it works, increases the table and columns, but when I click the button again to decrease the table (enter the if) table is lowered but columns remain large.

1 answer

0

Try to include the method setPrefWidth(tabela * valor), within the method redefineColunas(double tabela), to set the preferred column width.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.