![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() | |
![]()
|
|
|||||||||||||
Puzzle15 Sample AppletThe Puzzle15 sample is a fun and challenging demonstration of property sheets, marquees, and other controls.
DescriptionWhen the applet first loads, a Property dialog box is displayed showing the game options. The Scrambling Spinner edit control is used to enter the number of moves the puzzle will be scrambled. The Competition check box control determines whether a separate puzzle solver thread will be started. The Navigation property page determines the effect on the puzzle when the arrow keys are pressed.
When a button is adjacent to (or in the same row or column) the blank space, pressing the SPACEBAR or the ENTER key will cause the button with the focus to move in the direction of the blank (as if the button had been pressed by the mouse). The Marquee provides status on the solver thread, as well as the user's status relative to the solver thread. The Statistics panel informs the user on the number of moves he or she has made so far, and the minimum number of moves from the current position that will be required to reach the goal. This is the cumulative distance of each button to its goal position. For example, if the "1" button is in the bottom right corner, it will take at least six moves: up three rows, and then left three columns, to get it to its goal position, which is the top left corner. The Statistics panel also displays the number of moves in the optimum solution, as determined by the solver thread. The solver thread uses an iteratively deepening, depth-first search algorithm to determine the optimum solution. When the solver has found the optimum solution, the optimum solution text changes from At Least X Moves to Exactly X Moves. The Puzzle15 application and applet demonstrate the use of property sheets (UIPropertyDialog, UIPropertyPage), message boxes (UIMessageBox), menus (UIBandBox, UIBand, UIMenuButton, UIMenuList, UIMenuItem, UILine), buttons (UICheckButton, UIRadioButton, UIPushButton), and various other UI controls and classes (AWTUIApplet, UIApplet, UIFrame, UIPanel, UIGroup, UIViewer, UIGraphic, UIText, UIButtonBar, UISpinnerEdit, UIGridLayout, UIBorderLayout, UIVerticalFlowLayout, UISplitLayout). Menu Options:
SourcesThis sample applet consists of the following sources:
|
![]() |