简体   繁体   中英

Multithreading with automatically moving JButtons for Sliding Puzzle Solver

I created a sliding puzzle program using java. And then, I continued to implement sliding puzzle solver program.The problem is that when I click "play the result" button, the program is to automatically slide valid squares to goal state like this n-puzzle-solver.appspot.com . I created this game using JButtons with two dimensional arrays like this(btnTiles[0][0]). Can I implement it with Multithreading? If I can, please teach me an example or give me a link for multithreading with automatically moving JButtons.

You may able to leverage the approach shown here , which paces the timing on a thread owned by an instance of javax.swing.Timer . The example moves all the tiles at each interval, but you can just move one in the List .

图片

automatically moving JButtons.

wrong way to do it - leave the buttons alone, just change the icons (swap with blank)

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