Posts

Showing posts with the label Event Handling

Program to create a Popup Menu using Java AWT

Image
This tutorial shows you how to create a simple popup menu in Java. Popup menu is a menu which appears when you right click on mouse. For example, to copy, paste something in computer you right click and it will show the popup menu like:

Program to create a simple mini paint application

Image
In this program, we will create a simple mini paint application using Frame class. We have to implement two types of events here: Mouse event and Key event. To use this program you have to use numpad keys on keyboard. The following keys are used for specific purpose:

Program to demonstrate the Mouse events using Applet

Image
In this program, we have to implement Mouse events. An event which indicates that a mouse action is occurred in a component. This event is used both for mouse events (enter, click, press, release, exit) and mouse motion events (moves, drags). 

Program to use MouseListener interface and its methods.

Image

Program for dynamically creating and adding JLabels

Image
In this Java Swing tutorial, we will learn how to create JLabel components dynamically inside a JPanel based on the value entered in a JTextField . Whenever the user types a number, the application automatically creates that many labels and displays them in the panel without restarting the program. For example: If the user enters 3 , three labels will be displayed. If the user enters 5 , five labels will be displayed. If the text field is cleared, all labels are removed.