2

I'm implementing a GUI for a game (Qwirkle) which does not have a fixed board size. It dynamically grows when placing tiles next to another tile (with same color or shape).

Basically, I have an x,y-plane which grows dynamically when placing tiles. I have a function which gives the the bounds in an array[4] (left, top, right, bottom) such that I know what I have to display in the GUI.

Now I'm looking for a way to update the GUI's x,y-plane everytime new tiles are placed. Every tile is represented as a button and can be selected when the button is empty (meaning the empty tile, or no tile).

So if a tile (x,y) is placed ((0,0) initially), I want a x,y-plane with from -1 to 1 (fot both x and y). Then when a tile is placed on (1,0), the (x,y)-plane should be updated with new bounds. Preferably buttons should be a square (so a GridLayout might not be a good option?). So I have a fixed Jpanel in which the x,y-plane is centered and expands dynamically.

Any ideas how to display such a game?

Qwirkle (idea of how tiles can be placed)

1 Answer 1

1

I would suggest Null layout (setLayout(null)) and manipulate the location using setBounds.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.