正在加载图片...
ListBox Processing the User Selection selection colorIst. getselectedIndex()i The use of public constants if(selection ListBox. NO SELECTION) NO SELECTION and messageBox. show("You made no selection")i CANCEL makes the code more readable It also makes the modification of else if (selection = ListBox CANCEL code easier messageBox. show ("You canceled the ListBox else if(selection 0) messageBox. show("You selected Magenta) else if(selection = 3 messageBox. show(You selected blue")i else if(selection messageBox. show("You selected Green")i C 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 6© 2000 McGraw-Hill Introduction to Object-Oriented Programming with Java--Wu Chapter 6 - 23 ListBox – Processing the User Selection selection = colorList.getSelectedIndex(); if (selection == ListBox.NO_SELECTION) messageBox.show("You made no selection"); else if (selection == ListBox.CANCEL) messageBox.show("You canceled the ListBox"); else if (selection == 0) messageBox.show("You selected Magenta"); else if (selection == 3) messageBox.show("You selected Blue"); else if (selection == 4) messageBox.show("You selected Green"); The use of public constants NO_SELECTION and CANCEL makes the code more readable. It also makes the modification of code easier
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有