TAILIEUCHUNG - Java Programming for absolute beginner- P16

Java Programming for absolute beginner- P16:Hello and welcome to Java Programming for the Absolute Beginner. You probably already have a good understanding of how to use your computer. These days it’s hard to find someone who doesn’t, given the importance of computers in today’s world. Learning to control your computer intimately is what will separate you from the pack! By reading this book, you learn how to accomplish just that through the magic of programming. | 2 25 03 8 53 AM Page 258 k 0 c c 0 2 V The output for this application is shown in Figure . Within the itemState-Changed ItemEvent method two string objects are built based on which event occurred. The getStateChange method determines whether the item was selected or deselected by comparing the returned value to or . The program then obtains the value of the item depending on what type of component it is. The getItem method in the ItemEvent class returns an Object object that represents the item that triggered the event. For the Checkbox and the Choice this works out great because the object returned is a string that can be added to the Event string. For the List however I had to use the code Integer .intValue 0 a c E E s k a o k a s s figure ItemEvents are triggered by Checkboxes Choices and Lists. because returns the Integer index of the List item that was either selected or deselected. I had to explicitly cast it to an Integer object and call its i ntValue method which returns an int type value of the Integer object. Then I had to take that intvalue and pass it into int so that I could get the String value of the List item. Table lists some of the more common ItemEvent fields and methods. ItemEvent Fields and Methods Field or Method Description int DESELECTED Signifies that the ItemEvent occurred because an item was deselected. int SELECTED Signifies that the ItemEvent occurred because an item was selected. int getStateChange Returns a value either or depending on what type of state change is associated with this ItemEvent. Object getItem Returns an Object that represents the item whose state changed. team Line - live informative Non-cost and Genuine Please purchase PDF Split-Merge on to remove this watermark. 2 25 03 8 53 AM Page 259 Handling AdjustmentEvents The