if you set full size to the Label (or any component), it will occupy all the space available to it. In this case it means that the Label will occupy the whole cell of your GridLayout, and the alignment has no effect anymore.
What is the end result you want to achieve, and why do you need to enable the full height also?
During a click event on a grid cell, the label content in this cell should be updated with a new String or deleted with a empty String.
For this, I used a
LayoutClickListener on my grid and i get the label with a
( (Label) event.getChildComponent() )
The problem is that if the label is not full size, the user can easily launch a NullPointerException with a click in the red area next to the white label. And if I catch the NullPointerException, the user don’t understand why the label is not updated…
The best way would be to retrieve the coordinates of the clicked cell on the grid and make a
getComponent (XCell, yCell) but I do not know if it’s possible.
I found a solution to get the clicked cell of a GridLayout :
public void layoutClick(LayoutClickEvent event) {
// I divide the x position of the clicked event ([i]
event.getRelativeX()
[/i]) by the number of columns ([i]
cols
[/i]) and the total width of the grid ([i]
grid.getWidth()
[/i])
int coordX = (int) (event.getRelativeX() / (grid.getWidth() / cols));
// The same with the y position
int coordY = (int) (event.getRelativeY() / (grid/getHeight() / rows));
// I change the value of the (coordX , coordY) label of the grid
((Label) getComponent(coordX, coordY)).setValue("309 158 125 145");
}