Arvutiteaduse instituut
  1. Kursused
  2. 2018/19 kevad
  3. Objektorienteeritud programmeerimine (Narva Kolledž) (LTAT.NR.003)
EN
Logi sisse

Objektorienteeritud programmeerimine (Narva Kolledž) 2018/19 kevad

  • Home
  • Materials
  • Java Glossary
  • Source Example
  • Cheat sheet (S1-S6)
  • Grading
  • Links
Session 9

Introduction

The Before 8 material focuses on the basics elements of JavaFX programs. Nevertheless, one important part is left out there - the event handling. Most GUI controls generate events and channel the program flow.

An event can be defined as a signal to the program that something has happened. Events are triggered by external user actions, such as mouse movements, mouse clicks, and keystrokes. The program can be programmed to respond or ignore the triggered event.

In JavaFX, any event is an instance of class javafx.event.Event or any subclass of Event. Every event includes information about the event type, the event source and the event target. Therefore, the events can be divided into DragEvent, KeyEvent, TouchEvent etc.

Each event type can further be classified within its class. For example, the KeyEvent class contains the following event types: KEY_PRESSED, KEY_RELEASED, KEY_TYPED. In the subtypes, the event type ANY is used to mean any event type in the present event class. For example, to provide the same response to any type of a key event, use KeyEvent.ANY as the event type. To respond only when a key is released, use the KeyEvent.KEY_RELEASED event type.

A component that creates an event and fires it is called the event source object, or simply source object or source component. For example, a button is the source object for the buttonclicking action event. To respond to a button click, we need to write a piece of code that processes the button-clicking action. We need to create an object which is capable of handling the action event on a button. This object is called an event handler.

Used resources:

JavaFX tutorial "JavaFX: Handling Events".

Session 9
  • Arvutiteaduse instituut
  • Loodus- ja täppisteaduste valdkond
  • Tartu Ülikool
Tehniliste probleemide või küsimuste korral kirjuta:

Kursuse sisu ja korralduslike küsimustega pöörduge kursuse korraldajate poole.
Õppematerjalide varalised autoriõigused kuuluvad Tartu Ülikoolile. Õppematerjalide kasutamine on lubatud autoriõiguse seaduses ettenähtud teose vaba kasutamise eesmärkidel ja tingimustel. Õppematerjalide kasutamisel on kasutaja kohustatud viitama õppematerjalide autorile.
Õppematerjalide kasutamine muudel eesmärkidel on lubatud ainult Tartu Ülikooli eelneval kirjalikul nõusolekul.
Courses’i keskkonna kasutustingimused