130 likes | 283 Views
JAVA GUI Graphical user interface. Eng. Amr Nagy. Introduction. GUI presents a user-friendly mechanism for interacting with an application.
E N D
JAVA GUI Graphical user interface Eng. Amr Nagy
Introduction • GUI presents a user-friendly mechanism for interacting with an application. • GUI (pronounced “GOO-ee”) gives an application a distinctive “look” and “feel.” Providing different applications with consistent, intuitive user interface components allows users to be somewhat familiar with an application, so that they can learn it more quickly and use it more productively.
Simple GUI-Based Input/Output with JOptionPane // obtain user input from JOptionPane input dialogs String firstNumber = JOptionPane.showInputDialog( "Enter first integer" ); // display result in a JOptionPane message dialog JOptionPane.showMessageDialog( null, "The sum is " + sum,"Sum of Two Integers", JOptionPane.PLAIN_MESSAGE );
Event-Driven Programming • Code is executed upon activation of events. • An event can be defined as a type of signal to the program that something has happened. • The event is generated by external user actions such as mouse movements, mouse clicks, and keystrokes, or by the operating system, such as a timer.
The Delegation Model An event is triggered by user actions on the source object; the source object generates the event object and invokes the handler of the listener object to process the event.