When you perform an action on a graphical component you generate an event. In event-driven programming the program responds to these events. The order of the events is determined by the user, not the program.
This is different from programs where user interaction is done through the console. In these programs, prompts are written to the console, and the user responds to the prompts. The order of the prompts is determined by the program.
If your browser is written in Java, then Swing components generate the events and Java methods respond to them. If your browser is written in C++, then it uses other components and methods, similar to Swing. (Most browsers are written in C++).
How do you imagine that I wrote this Web page: