Skip to content
stefvanschie edited this page Dec 19, 2022 · 3 revisions

Languages: Dutch (Nederlands)

Slots

Instead of specifying the coordinates in the pane directly, you can also make use of a slot. A slot specifies a position, but allows you to specify the position in different ways. There are two ways to specify a position: from an x and y coordinate pair and from an index.

XY coordinates

Specifying an x and y coordinate pair works the same as specifying the coordinates directly in the pane. Specifying them directly in the pane simply acts as a simpler way to achieve the same thing. If you want to be explicit, you can also use a slot.

StaticPane pane = new StaticPane(Slot.fromXY(0, 0), 9, 6);

Index

The second way to specify a position is via an index. An index specifies the position by counting the slots in the parent container, from left to right, top to bottom. The position is where this count overlaps with the index. For example, when placing a pane in a gui of size 9 by 6, index 28 would correspond to position (3, 1) as x and y coordinates (3 * 9 + 1 = 28).

StaticPane pane = new StaticPane(Slot.fromIndex(28), 9, 6);

These slots work in any place where a position is required, such as the positions of panes and items.


It is possible to use either method of specifying positions in your project, however be careful when mixing these two types within the same container. Since the position of indexes depend on the width of the parent container, it is possible for panes or items to overlap one another. This may cause issues in for example a Static Pane where items are not allowed to overlap each other. It is recommended to pick one style of specifying positions and to stick to that style for your entire project.

Clone this wiki locally