简体   繁体   中英

How to make a checkerboard of JButtons

I need to make a checkerboard that is composed of alternating black and white JButtons, that are right up against another. Can I use the graphics class to add buttons? I would appreciate help not answer as this is homework.

Take a look at the GridLayout you can find examples on how to use ithere . Lastly, I think that using JPanels will give you a better finish than using JButtons if you want to create a checkered board, but that is entirely up to you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM