Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS 251
Lab Exercise #11
Due: In Lab, the week of May 9th, 2011.
Main topics: GUI
Swing
This week we will be practicing using some of the basic GUI swing components.
Getting Started To start this exercise, you should first change into your lab directory and create
a directory named 11. You should then change into this new 11 directory and type the
following command:
cp /home/CS/cs251/pub/lab11/* .
Eclipse 1. Open Eclipse
2. Open a new java project named Lab11
3. Import the java files that you just copied into your project. File -¿ Import -¿ General -¿
File System -¿ Browse
GUI.java A very simple ”Skeletal” class which you can use as a base.
Your job is to:
1. write the code for the createContents method - set myText and myLabel to
appropriately constructed graphical components and add them to this.
2. write the code for the actionPerformed method - get and set the text values of the
appropriate graphical components text values so that when the return key is pressed:
• The text value of myText will be ”safely” parsed to an int value.
• If that int value is less than 36 than the text value of myLabel is set to a message
expressing youth.
• (else)If that int value is less than 46 than the text value of myLabel is set to a
message expressing middle age.
• (else) the text value of myLabel is set to a message expressing mature stature.
• If the parsing did not succeed than the text value of myLabel is set to a message
expressing the need to enter an Integer.
Compile build and run the class, and fix any errors.
Check off 1. Once you finish this lab, you should see your Lab TA to let them know you are
finished with this lab so that they can check you off.
1