Posts

Program to create a simple Calculator using Java AWT components

Image
This tutorial explains you how to create a simple Calculator using Java AWT components. The output of the program is given below. 

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). 

Pascal triangle 5

Image
This program will display the pascal triangle or print star pattern as shown below: * *A* *A*A* *A*A*A* *A*A*A*A*

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.

Program to demonstrate "HashMap" class in Java's Collection Framework

The  Map  interface maps unique keys to values. A key is an object that you use to retrieve a value at a later date. Given a key and a value, you can store the value in a Map object. After the value is stored, you can retrieve it by using its key. It stores value in pairs i.e key and value we can store data using put( ) method and fetch specific data using get( ) method we can print all data using entrySet( ) method. It has following methods: void clear( ) :  Removes all key/value pairs from the invoking map. boolean containsKey(Object k) :  Returns true if the invoking map contains k as a key. Otherwise, returns false. boolean containsValue(Object v) :  Returns true if the map contains v as a value. Otherwise, returns false.