Reputation: 659
I have assigned myself the task of making the board game HEX and I am not sure how to make the backing for the board, I am currently thinking about using JButtons; however, I do not know how to make a hexagonal Jbutton and I am struggling finding out how. I am still new to java so please talk like you're teaching a four year old how to code. Many thanks.
UPDATE: I have tried using buttons with a hexagonal picture implemented this does not support the tiling feature of HEX.
Upvotes: 2
Views: 266
Reputation: 22343
I would suggest that you use an Image for your JButton
. So you create an image with a hexagon and use it for your button:
ImageIcon yourImage = new ImageIcon("pathToYourImage");
//Clean the button
yourButton.setContentAreaFilled(false);
yourButton.setFocusPainted(false);
yourButton.setBorderPainted(false);
//Set the image
yourButton.setIcon(yourImage); //or new JButton(yourImage);
Upvotes: 1