File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Puzzle Solver

 
Jane Florence
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am new in this forum and this is my first post.
I am doing an assignment of the number puzzle solver and my deadline is approaching. I have created the GUI and the layout only. So what I left to do is to create methods to listen the action from all those JButtons, such as shuffle, clockwise, anticlockwise, swap and push. If you know how to do one or two (or more) methods, just post please. I am seriously urgent and seeking people to contribute ideas. I just attached the picture of GUI that was created. Hope somebody can help me!

Here is the some of the criteria of how the JButton should work.
http://goo.gl/pUIIO
puzzle.JPG
[Thumbnail for puzzle.JPG]
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

That is not quite how we operate here. You should tell us what you have done, and whether it is working. Then we shall be happy to help you with yoru problems.
I shall move this discussion because you have managed to land in the wrong place.
There are a few words we never use: one of them is “urgent”.
 
Jane Florence
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that... I am so sorry to have bad impression in my first post!

 
Jane Florence
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is all what I have done so far.



 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added code tags, which you should always use, and you can see how much better it looks.
What is the actual problem? Are your buttons not being enabled, or are they not activating their listeners. I suggest, just for a start, you implement the methods like thisThat code will show you that you are successfully calling those methods. You can then replace it with something more useful.

Use spaces. not tabs for indenting. Why have you imported FlowLayout, which you appear not to be using? FlowLayout is pretty useless, anyway.
Have you really got two }} between the genSwap and genPush methods? That is probably a mistake, and you might get all sorts of compiler errors because of that additional }
 
Jane Florence
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply and sorry for my late reply.
My problem now is that I have difficulty in how to write methods for rotating clockwise and anticlockwise.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the algorithm for rotating? You need to work that out before you can implement those methods.
 
Jane Florence
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The logic is that when we rotate clockwise, let's say 4x4 table, row 1 becomes column 4, column 4 becomes row 4, row 4 becomes column 1 and column 1 becomes row 1. And the middle 4 cells also rotate in that way. When you look at the picture, I think it will be more clear about the logic.
original.JPG
Before rotating
[Thumbnail for original.JPG]
clockwise.JPG
After rotating clockwise
[Thumbnail for clockwise.JPG]
anticlockwise.JPG
After rotating anticlockwise
[Thumbnail for anticlockwise.JPG]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic