First, as pointed out by Campbell Ritchie, here is the algorithm (I thought it was too trivial so did not want to waste space on it)
This is what the code does:
1. On Init, populate the ArrayList<Component> Numbers with one blank label and 15 buttons representing the 15 digits. The ArrayList is shuffled and then displayed in the GridLayout
2. On any button press.. check if that button has the blankLabel as a neighbor. If it is, just swap the position.
I found a solution to this problem.. posting it here to complete the
thread..
The problem is that the components remembered their location. That is, even after call to
The location of the components did not reset. They were added in a different order every time, but since they remembered their location, they got placed in the same old place.
When I explicitly reset their location using setLocation(), the problem got solved.
But the question
Thank you all for your help