Browse DevX
Sign up for e-mail newsletters from DevX


Introduction to Java Interface Event-Handling

Java is an event-driven language. This means that program flow usually varies dependent upon what actions a user performs, and differs from traditional procedural-based languages where program execution was very linear. Here's what you need to know to make your Java programs respond to events such as the user moving the mouse or clicking a button.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

hen you program with event-driven languages, users typically see an interface containing controls, buttons, menus and other graphical elements. After displaying the interface, the program waits. What happens next depends almost entirely on the user.

Usually, that means users interact with the controls to make something happen. For example, a user may click a button, or choose a menu item. Whatever users choose to do, they will initiate an event, which in turn, fires code in an event-handler, which is a part of the program coded respond to the specific event. After handling the event, the program waits for the user to do something else.

With that in mind, event-driven interface programming becomes a matter of setting up an interface that responds to the user's actions. The program becomes a collection of bursts of code that are modular in fashion and tied specifically to possible actions.

In contrast, linear-based procedural programs provide limited user options. The program retains the bulk of the control.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date