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

Bàn làm việc gọi createPartControl () khi xem được khởi tạo. Ở đây, trước tiên bạn phải tạo một Canvas, thiết lập màu nền của nó, và gán một phím để giúp tình huống nhạy cảm với nó. Giao diện HexHelpConstants được liệt kê ở đây. Sau đó, bạn cần phải tạo ra các trường hợp của các hành động được định nghĩa trước đây | Project 4 The Hex Game as a Rich Client Application The workbench invokes the createPartControl method when the view is initialized. Here you must first create a Canvas set its background color and assign a key for context-sensitive help to it. The HexHelpConstants interface is listed here. Then you need to create instances of the actions defined previously and to add these actions as tool buttons to the title bar of the view. Finally you must create an instance of the game engine and configure it and then you start the first game. Constructs the view content public void createPartControl Composite parent canvas new Canvas parent .getSystemColor canvas makeActions contributeToActionBars game new Game this canvas When you create a single action its identification the display label a tool tip and a key for the contextsensitive help are specified to construct the instance. The actions for color and level selection are constructed as toggle actions the others as normal actions. Create actions private void makeActions newGameAction createAction NEWGAME_ACTION New Game Starts new game whiteAction createToggleAction WHITE_ACTION White Player plays white true blackAction createToggleAction BLACK_ACTION Black Player plays black false basicAction createToggleAction BASIC_ACTION Basic Basic Level true advancedAction createToggleAction ADVANCED_ACTION Advanced Advanced Level false helpAction createAction HELP_ACTION Help Help for Hex null Create single action @param id - Identification 523 Chapter 15 param label - Display label param tip - Tooltip param helpId - ID for context sensitive help return - the created action .

TỪ KHÓA LIÊN QUAN