Unit 3: Event driven architecture Flashcards
What is sequential programming?
A programming approach where the program is in control and user input occurs in a predefined sequence.
What is event-driven programming?
A programming style where the user controls the flow through actions (events), and the program responds accordingly.
Give an example of sequential programming.
A command-line program prompting the user for input step-by-step.
Give an example of event-driven programming.
A GUI app with buttons for simulating cars entering and exiting a car park.
What is an event in programming?
An action like a button press, mouse click, or window resize that occurs and the program can respond to.
What is an event handler?
A method that is automatically called in response to a specific event, such as a button being pressed.
What is the event loop?
The continuous cycle of waiting for an event, reacting to it, and then waiting again.
Who runs the event loop in Java GUI applications?
The Java Virtual Machine (JVM).
What method is used to handle button clicks in Java?
public void actionPerformed(ActionEvent event)
What does event.getSource() do in Java?
It checks which GUI element (like a button) triggered the event.
How do you update a text field in Java GUI?
Using text.setText(“your text here”).
What happens in the actionPerformed method?
It reacts to events like button presses by running specific code depending on the event source.