Event Driven Programming in Java:
The previous section, has shown you how to create graphical user interfaces that contain a wide range of components and have quite sophisticated layouts. You are also in a position now to make use of Java reference material to investigate and use other components and layouts. However, when the user clicks on a button or enters text, nothing happens. This is because there is no link between the graphical user interface and the code that you would like to be executed.
Creating this link between something happening in the graphical user interface - an event - and the execution of code is the subject of this unit. This subject is commonly known as event-driven programming. Event-driven programs are programs that respond to events initiated by the user, such as mouse clicks and key presses. Events can also be initiated through software coding, using for example the Timer class, which may specify that certain events are to take place at certain times. However, this course will consider only user-initiated events.
Event-driven programming represents an entirely different style of programming. All of the code that you have worked on so far has been fairly 'linear' in nature - it has been possible to plot a route through the code to show the order of execution. However, with event-driven programming this is no longer necessarily the case. Essentially, components are waiting around for an outside body - the user - to initiate an event through one of the visual components - clicking a button, for example. But you, the programmer, do not know when the button will be pressed, whether a number of buttons will be pressed, or in which order the user will press them.
You will see that a major part of event-driven programming is the creation of objects called listeners that are attached to components. As their name suggests they 'listen' for events happening to 'their' components. These listeners then 'fire' off the desired code. Listeners can be 'told' to look at particular components and to look only at particular events. For example, a listener may be interested only in a mouse entering a particular part of the screen and not in it being clicked.
We will also continue with the Calculator example started in the last unit. In this part we show how the action of the user clicking on a button can be linked to the code that will carry out the actions and then display the result.
In this unit, we aim to:
- introduce event-driven programming;
- show how to link external events to program code;
- introduce the Graphics class and simple animation;
- give you an overall view of the construction of working GUIs through a number of fully developed examples.
Java Assignment Help - Java Homework Help
Struggling with java programming language? Are you not finding solution for your Event Driven Programming in Java homework and assignments? Live Event Driven Programming in Java experts are working for students by solving their doubts & questions during their course studies and training program. We at Expertsmind.com offer Event Driven Programming in Java homework help, java assignment help and Event Driven Programming in Java projects help anytime from anywhere for 24x7 hours. Computer science programming assignments help making life easy for students.
Why Expertsmind for assignment help
- Higher degree holder and experienced experts network
- Punctuality and responsibility of work
- Quality solution with 100% plagiarism free answers
- Time on Delivery
- Privacy of information and details
- Excellence in solving java programming language queries in excels and word format.
- Best tutoring assistance 24x7 hours