Đang chuẩn bị liên kết để tải về tài liệu:
Java Programming for absolute beginner- P26

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Java Programming for absolute beginner- P26: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. | JavaProgAbsBeg-12.qxd 2 25 03 8 58 AM Page 458 k 0 c c 0 2 V 0 a c E E s k a o k a s s there s no mine in here it reveals the cell and dispatches a MineCellEvent.REVEALED event. If there is a mine in here it sets the color to col-ors MINE and dispatches a MineCellEvent.DETONATED event. Another anonymous inner class listens for MouseEvents. The superclass JPRButton3D doesn t do anything with right mouse clicks but this MouseAdapter does. It either flags or unflags this cell based on whether the cell is already flagged and dispatches the corresponding event. Another thing the MineCell class needed to take care of was to prevent action events from mine cells that are flagged. You don t want to let the player click a flagged cell and blow up right Nor do you want the cell to be animated. You want it to be concrete that if this cell is flagged you can t click it with the left mouse button period. To accomplish this the MineCell class overrides the processMouseEvent MouseEvent method. If this cell is not flagged or if you re right-clicking it just go ahead and let the MouseEvent pass but if this cell is flagged and you re trying to left-click it stop it dead in its tracks public void processMouseEvent MouseEvent e if flagged e.getModifiers MouseEvent.BUTTON3_MASK super.processMouseEvent e Here is the full source code listing for MineCell.java MineCell Defines one cell of the MinePatrol Game. import java.awt. import java.awt.event. import java.util.Vector import jpr.lightweight.JPRButton3D public class MineCell extends JPRButton3D protected int contents public final static int EMPTY 0 public final static int MINE 9 These colors are indexed by the contents Color EMPTY is for revealed cells and colors MINE is for detonated cells protected Color colors protected boolean hidden detonated flagged acts as the background color when the cell becomes visible protected static Image flagImg mineImg explodeImg protected Vector listeners public MineCell this EMPTY team Line - live .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.