Author: peteroyle
Date: 2009-10-01 09:30:33 -0400 (Thu, 01 Oct 2009)
New Revision: 3827
Modified:
examples/trunk/se/numberguess/readme.txt
Log:
Updated documentation to reflect API changes
Modified: examples/trunk/se/numberguess/readme.txt
===================================================================
--- examples/trunk/se/numberguess/readme.txt 2009-10-01 07:27:10 UTC (rev 3826)
+++ examples/trunk/se/numberguess/readme.txt 2009-10-01 13:30:33 UTC (rev 3827)
@@ -14,16 +14,17 @@
See the License for the specific language governing permissions and
limitations under the License.
====
-===================
+
+===========================
Swing Example: Number Guess
-===================
+===========================
Here's an example of a Swing application, Number Guess, similar to the example in
chapter 3.4.
In the Number Guess application you get given 10 attempts to guess a number between 1
and
100. After each attempt, you will be told whether you are too high, or too low. This
example can
be found in the examples/se/numberguess folder of the Web Beans distribution.
-There is an empty beans.xml file in the root package (src/main/resources/beans.xml),
which
+There is an empty beans.xml file in the META-INF package
(src/main/resources/META-INF/beans.xml), which
marks this application as a Web Beans application.
The game's main logic is located in Game.java. Some key points about this class:
@@ -56,7 +57,7 @@
order to determine the appropriate messages to provide as the prompt for the user's
next guess
and the response to the previous guess. Some key points about this class:
- The instance of Game for the application is injected here.
+ The instance of Game for the application is injected.
The Game's state is interrogated to determine the appropriate challenge message.
And again to determine whether to congratulate, console or encourage the user to
continue.
@@ -65,34 +66,34 @@
Finally we come to the NumberGuessFrame class which provides the Swing front end to our
guessing game.
- The injected instance of the game (logic and state).
+ The instance of Game for the application is injected.
- The injected message generator for UI messages.
+ The message generator for UI messages is injected.
- This application is started in the usual Web Beans SE way, by observing the
@Deployed
- Manager event.
+ This application is started in the usual Web Beans SE way, by observing the
+ ContainerInitialized event.
- This method initialises all of the Swing components. Note the use of the
msgGenerator.
- guessButtonActionPerformed is called when the 'Guess' button is clicked,
and it does the
- following:
+ The initComponents method initializes all of the Swing components. Note the use of
the msgGenerator.
+ guessButtonActionPerformed is called when the 'Guess' button is clicked, and
it does the
+ following:
- Gets the guess entered by the user and sets it as the current guess in the Game
- Calls game.check() to validate and perform one 'turn' of the game
- Calls refreshUI. If there were validation errors with the input, this will have
been
captured during game.check() and as such will be reflected in the messeges
returned
- by MessageGenerator and subsequently presented to the user. If there are no
validation
- errors then the user will be told to guess again (higher or lower) or that the
game has ended
- either in a win (correct guess) or a loss (ran out of guesses).
+ by MessageGenerator and subsequently presented to the user. If there are no
validation
+ errors then the user will be told to guess again (higher or lower) or that the
game has ended
+ either in a win (correct guess) or a loss (ran out of guesses).
- replayBtnActionPerformed simply calls game.reset() to start a new game and
refreshes
- the messages in the UI.
+ replayBtnActionPerformed simply calls game.reset() to start a new game and refreshes
+ the messages in the UI.
- refreshUI uses the MessageGenerator to update the messages to the user based on the
- current state of the Game.
+ refreshUI uses the MessageGenerator to update the messages to the user based on the
+ current state of the Game.
------------------
+-------------------
Running the Example
------------------
+-------------------
As with all Web Beans SE applications, this example is executed
by starting Java with org.jboss.webbeans.environment.se.StartMain