tailieunhanh - Professional Eclipse 3 for Java Developers 2006 phần 6

Trong thời hạn những người nghe, sự kiện kéo-anddrop được xử lý như đã được thảo luận trong phần "kéo-và-thả" trong Chương 8. Tuy nhiên, nếu bạn muốn trao đổi dữ liệu với người xem hiện tại, bạn phải biết loại chuyển giao được hỗ trợ bởi những người xem. | Project Two Jukebox public class Playlistwindow extends Window implements ISelectionChangedListener Playlistviewer viewer Player player IPlaylist model Constructor. @param parent - The containing shell @param player - The player public PlaylistWindow Shell parent IPlaylist model super parent model Listing Continued User processButton SelectionEvent void ToolItem activated 1 setInput Object void inputChanged Viewer Obiect Obiect void 1 1 1 playlist switched setCurrent Object void other playlist update 1 1 setInput Object void I_ insert Object I menu selection I _t x_. 1 menu selection 1 1 1 1 1 1 1 1 1 1 1 insert entry deleteCurrent void delete entry selectionChanged SelectionChangedEvent void table selection 1 LI 1 1 1 1 1 1 1 u 1 . 1 Ị selectionChanged SelectionChangedEvent void 1 selection changed 1 1 setSelection ISelection void i 1 1 1 1 select table entry 1 1 1 1 selectionChanged SelectionChangedEvent void 1 1 1 1 1 1 1 1 1 selection changed 1 1 Figure 279 Chapter 10 In the createContents method that is called from the parent class Window see the section Dialogs and Windows in Chapter 9 PlaylistWindow constructs the window content. In particular an instance of the class Playlistviewer a subclass of Tableviewer is created. This viewer is configured with the help of style constants horizontal and vertical scrolling is allowed only single table rows can be selected and the whole table row appears selected. Then the viewer is equipped with event processing. When a row is selected the selectionChanged method is invoked. This method retrieves the selection object from the event object. The selected table entry is the first element in the selection object. This table entry is passed via the method setCurrent to the playlist model to update the selection there. Finally the viewer is initialized by fetching the filename of the current playlist from the playlist model and passing this .

TỪ KHÓA LIÊN QUAN