Java Tutorial

Creating simple Calculator in Java

Submitted by mehfuza on

Introduction

This tutorial is about creating simple calculator which performs only four operations. For creating a simple Calculator we require two JTextFields where the user can enter two numbers, four JButton for four operations namely addition, subtraction,multiplication and division, a JLabel for displaying the result.

Implementation

Step 1: Creating a class which extends JFrame because we are going to create an Application. After this we have to define the constructor of the class as follows. Super() is used to give title to the frame.

Creating a Simple Paint Program in Java

Submitted by mehfuza on
Introduction In this tutorial, a simple Paint program is created, which enables us to draw anything to screen. It's a basic program to understand the logic behind creating a paint program. Here main concept is implementing MouseMotionListener which handles mouse events. Whenever mouse is dragged a mouse event is sent to Java which finds the event listener in the program in order to take any action. We need to implement only mouseDragged() of many functions of MouseMotionListener class to draw to the Panel.

Saving the Objects in Java

Submitted by mehfuza on
Our programs reside on Hard Disk. Every program is brought into Main memory(RAM) for execution. Variables, Objects are runtime entity which means they are saved in RAM. Once you run the Program, variables, objects come into existence but once we close our program they are deleted from the Main Memory. In order to save the state(instance variable) of objects they must be saved on Secondary Memory(Hard Disk). Following are steps for serializing(saving) the objects.

Easy Way to implement A Dynamic Clock in Java using Threads

Submitted by mehfuza on
Introduction: In this Tutorial, creation of clock which updates every second is explained. Here we create an Application for clock. It shows Hour, minutes and seconds which updates every second. Main Idea: The Dynamic clock can be created using Java's Timer thread but here we will see how to use our own thread and accomplish the task. This tutorial can clear any doubts you have in Java Threads.

What is BlueJ

Submitted by onyx_ash08 on
BlueJ is an integrated Java environment specifically designed for introductory teaching. BlueJ was developed at a University specifically for the purpose of teaching object orientation with Java. BlueJ is free!