Presentation is loading. Please wait.

Presentation is loading. Please wait.

Event Handling H_Func(Event) { } Event Receiver Object Source Object Registration.

Similar presentations


Presentation on theme: "Event Handling H_Func(Event) { } Event Receiver Object Source Object Registration."— Presentation transcript:

1 Event Handling H_Func(Event) { } Event Receiver Object Source Object Registration

2 Source vs. Receiver Source/ReceiverReceiver Source

3 Mouse Event Handling in Java Event: MouseEvent Interface: MouseListener ( mousePressed, mouseClicked, mouseReleased, mouseEntered, mouseExited) MouseMotionListener ( mouseDragged, mouseMoved) Adaptor Class: MouseAdaptor, MouseMotionAdaptor Registration: addMouseListener, addMouseMotionListener

4 Event-driven Programming Programming paradigm State representation State presentation : paintComponent in java Event handling and state change Request for presentation to reflect new state: repaint in java

5 Double Buffering Flicking problem Double buffering –Front buffer for display –Back buffer for composition Triple buffering

6 Single Buffering Frame Buffer Display Composition

7 Double Buffering in Computer Graphics Front Composition Display Back Front Display Composition Swap Buffers

8 Double Buffering in Java Front Composition Draw Back Image Window

9 Double Buffering in Java Step 1: Create the back buffer and its graphics Image backBuffer = createImage(width, height); Graphics gBackBuffer = backBuffer.getGraphics(); Step 2: Compose the scene in the back buffer gBackBuffer.clearRect(…); gBackBuffer.fillOval(…);.... Step 3: copy the back buffer to the front g.drawImage(backBuffer, 0, 0, null);

10 An Example Event-driven programming paradigm Class Array/Collection Event Handling Double Buffering


Download ppt "Event Handling H_Func(Event) { } Event Receiver Object Source Object Registration."

Similar presentations


Ads by Google