Heighten and Widen are the functions needed to enable the clients to place elements of different widths on top of each other, or place elements of different heights beside each other. These functions takes a width or a height and returns an element having the same width or height respectively.
For example, evaluating the following expression would not work correctly, because the second line in the combined element is longer than the first:
new ArrayElement(Array("geeks")) above new ArrayElement(Array("forgeeks"))
Similarly, evaluating the following expression would not work properly too, because the first ArrayElement has a height of two, and the second a height of only one:
new ArrayElement(Array("yes", "no")) beside new ArrayElement(Array("yes"))
The code fragment below contains a private function widen, which takes a width and returns an Element of that width. The result contains the contents of this Element centered padded to the left and right by any spaces needed to achieve the required width. Similarly, it contains another private function heighten, which performs the same function in the vertical direction. The widen method is invoked by above to ensure that Elements placed above each other have the same width. Similarly, the heighten method is invoked by beside to ensure that elements placed beside each other have the same height.