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 redefineColunas
method should set 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 percentages for each column, when it goes into else
it works, it increases the table and columns, but when I click the button again to decrease the table (enter if
) the table is decreased but the columns are still large.