-->

Wednesday, October 8, 2014

Life Cycle of applet

In the previous article, we have already learned about basics of applet.

Life Cycle of applet

1. init() : init method is used to initialize the applet. Before doing anything, must to initialized, so same thing with the applet. Like, in the games.
Before play any games, must to initialized all the  drivers in the system, which is necessary for the games. In the applet, init method is invoked only once, also that method invoked after param tag, which is inside in <applet></applet> tag.

2. start() : This is invoked after the initialization completed. It is used to start the applet, also automatic start. When user navigate to the web page, if
web page contain applet code then it start automatically also start when user moves from other web pages.

3. paint () : This method is invoked just after start() method. Actually only this method is responsible to design the applet, also responsible for repaint the browser, if applet is stooped. It has contain graphics argument as a parameter, through Graphics class we can design any graphics in the applet like rectangle, oval etc. Graphics class inherit from java.awt class.
4. stop() : This method is invoked, just after when the user moves to other browser tab from current applet tab.

5. destroy() : This method is invoked only that time when user close the browser. You can say, opened web page contain applet code , on that time applet is running
properly but in case if user close the browser, applet instance is automatically deleted from the page and destroy method is called automatically.

Example of Applet

The following is a simple applet named HelloWorld.java

import java.applet.*;
import java.awt.*;
public class HelloWorld extends Applet
{
public void paint (Graphics g)
{
g.drawString ("Hello World", 30, 50);
}
}

The first line of code define, imports some packages, which is used for design the applet. Here are two class that is applet and awt. In the second line of code, we have a class "HelloWorld" which is inherited from Applet class. This Applet class inside in java.applet.* package. Through the Graphics class, we can design new object in the applet. This class inherited from java.awt.*. In this example, we have to draw a string with height and width argument(width=30, height=50).
With the help of applet tag, we will show the output in any browser, which support applet. Applet tag is:
  <applet code="HelloWorld.class" width=50 height=60></applet>

This tells the viewer or browser to load the applet whose compiled code is in HelloWorld.class (in the same directory as the current HTML document), and to set the initial size of the applet to 50 pixels wide and 60 pixels high.

Monday, October 6, 2014

Basics of applet

Applet is a small java program that run in browser, but JVM is required for run applet in browser. Basically applet is used where user want to put some dynamic content into html page.
There are some features and advantages of Applet

Features:


  1. It is a java class file, which is inherit from java.applet.Applet class.
  2. A applet class file don't take main() method for entry point.
  3. Applet codes are embedded in HTML page
  4. For run the applet code in browser, must to install JVM in the client machine
  5. During the execution of applet code in browser, code first to download in the client machine.

Advantages:


  1. Very less response time because Applet designed for client machine. If applet is used for server machine then server take more time to execute applet code.
  2. More secure
  3. Platform independent, so it can run on any platform that is windows, Linux, UNIX, etc.
  4. Use for dynamic application


Disadvantages of applet


  1. For run to its code in browser, must to installed JVM plugin

Thursday, October 2, 2014

Forms of JavaBeans

In the previous article, we have already learn about basic concept of java bean, today i am talking about java beans forms.
Java Beans can appear in two forms:
  1. Visual
  2. Non visual.
Visual is more common, as the majority of Java Beans are extensions of Swing or AWT components. Some Beans may be simple GUI elements such as a specialized button or slider. Others may be sophisticated visual software components such as a diagram component offering different ways to present the bounded data. They all have in common that they can be customized at design time in a builder tool.

Java Beans can also be non visual yet still be customizable using a builder-tool. They do not have to be derived from a specific class or interface, it is recommended that they implement the Serializable interface. In respect of the source code there is no real difference noticeable between a Java Bean and a “normal” Java class. Basically what differs the source code of a “normal” class from a Java Bean is that the latter adheres to the Java Beans API specification in terms of how it is developed. Only the strict adherence to this specification ensures that builder tools can assist a developer to work with Java Beans. For many solutions you can either develop a conventional Java class where you have to write your own code for setting its properties or you can build a Java Bean which allows you To set the properties through the builder tool. Eventually both methods result in code just that in the latter case the builder tool creates the code automatically in the background according to your selection.

Introduction of JavaBeans

A Java Bean is a software component that has been designed to be reusable in a variety of different environments. There is no restriction on the capability of a Bean. It may perform a simple function, such as checking spelling of a document, or a complex function, such as forecasting the performance of a stock portfolio. A Bean may be visible to an end user. One example of this is a button on a graphical user interface. A Mean may also be invisible to a user. Software to decode a stream of multimedia information in real time is an example of this type of building block. A Bean may be designed to work autonomously on a user’s workstation or to work in cooperation with a set of other distributed components. Software to generate a pie chart from a set of data points is an example of a Bean that can execute locally.

A Bean that provides real-time price information from a stock or commodities exchange would need to work in cooperation with other distributed software to obtain its data.

Java Beans components, or beans, are reusable software components that follow simple naming and design conventions so they present a standard interface to other beans, programs, and tools. In the next video tutorial i will learn about forms of java beans.

Wednesday, October 1, 2014

File types, Text and Binary in C

As discussed earlier the C language provides flexibility for the programmers to write file handling programs to store and process data. Such data files contain the data effectively in two formats. So, on the basis of the format structure of the files are of two types, Text File and Binary File.

Text File

In a text file a stream of characters are stored sequentially without any formatting. So, it is very simple to handle but direct access is not possible because any value or character is not stored after fixed number of bytes. Even though the numbers are stored in the form of characters only and the record length is not fixed if the records are stored. Again the records are also stored in the character format of the individual fields.

Similarly, since text files only process characters, generally they can only read or write data one character at a time. But the flexible C Language provides file handling functions to read and write formatted data and lines of text in a text file. But these functions again basically process data one character at a time. The normal functions used to handle the text file are getc(),fgetc(),fgets(), fputs(), putc(),fputc(),fscanf() and fprintf(). These functions transfer the character/s to and from the text file.

Depending on the requirements of the OS (Operating System), newline character may be converted to or from carriage-return/linefeed combination depending on the data is being written to, or read from, the file. Other character conversions may also occur to satisfy the storage requirements of the OS. These translations occur transparently and they occur while processing a text file.

Binary File

A binary file is not much different to a text file. It is also a collection of bytes. But the transfer of data is purely in the form of bytes as stored in main memory. Any number of bytes can be transferred at a time, in binary file. But the length of the bytes transferred is fixed. So, the binary files contain the data in fixed length record format. That is the reason they are more effective than text files. One important advantage of fixed length is that of accessing the record directly. The direct access is possible only in case of the binary files. It is basically because when a record is written to a binary file form the memory, the complete memory block is written. The number of bytes transferred is fixed. In the same manner when the data is read from the binary file the number of bytes is transferred to the memory at the provided address. The file handling functions provided to handle the binary files are fread() and fwrite(). This fixed length transfer is advantageous for direct access but the size of the file increases. So, in comparison to text files the binary files are advantageous in direct access at the cost of the size. Thus a selection of type of file is decided keeping the accessibility of data in mind.

A binary file is also referred to as a character stream but differ in the following ways:

• No special processing of the data occurs and each byte of data is transferred unprocessed to or from the disk.

• C Language places no constraints on the file, and it may be read from, or written to, in any manner.

Binary files can be either processed sequentially or randomly. The processing of a binary file using random access techniques involves moving the file pointer position to an appropriate place in the file before reading or writing data. This indicates a second characteristic of binary files; the binary files are generally processed using read and write operations simultaneously. For example, for the creation and processing a database file the best choice is a binary file. A record update operation will involve locating the appropriate record, reading the record into memory, modifying it in some way, and finally writing the record back to disk at its appropriate location in the file. These kinds of operations are common to many binary files, but are rarely found in applications that process text files.

The type of the file to be processed is decided at the time of opening a file. At the time of opening a file the mode of operation is mentioned indicating text file or binary file. The function fopen() provides the capability of opening a file. By default the file is opened in text mode. If the binary file is to be processed then it is explicitly defined as “b” along with the other required mode character ‘r’, ‘w’ or ‘a’.

When the file is opened the mode of operation is specified. It indicates the types of files “text” and "binary". The text file is advantageous in terms of size and the binary file in terms of random or direct access.

Online Movie ticket booking System project in ASP.NET

Introduction 

Through this software, You can reserve your movie hall ticket online. Basically this system categories in two parts, the first part related to visitor who want to book ticket and second part is related to admin who handle all the privileges like user account, payment account etc. When visitors visit the home page of this site then they will see the first interface of the project that is movie name with full description and book now button. When visitors click on book now button then they will go to the next page that is login page. If the visitors are authenticated person then no need to register again, simply login into the account. After login they will see the seat no , visitor can reserve multiple seat at a time.

Module of the project

  • Viewer module
  • Admin module

Software requirement to run this software

Visual Studio 2013 and windows 8

How to run this project

1. First to open the project in visual studio 2013 
2. Click to green color of triangle button, also you can use ctrl+f5.

Project Module

1. Visitor, who want to reserve seat
2. Admin

Snap Shot of the project

Ticket Booking snap

Ticket Booking snap

Ticket Cancel Snap

Ticket Cancel Snap


How to Download the project

Mail me : narenkumar851@gmail.com

Tuesday, September 30, 2014

File Pointer in C

In order to use files it is mandatory to learn the file Input / Output operations. Learning of these is nothing but to understand the functions to write data into a file, to read data from a file, etc. For at any of such operations the file must be opened. The file opening operation is done through a pointer variable called as file pointer. So, file pointer is nothing but a variable which is declared and then I to any required physical file. All the I/O operations are done to physical file through the logical file.

A File Pointer is a special type of pointer variable of the type FILE that is used to store the address of a physical file.

FILE I/O is almost identical to the console and terminal I/O operations. The pnntf() function is used to display the data on the screen. And in file handling we use fprintf() to write the data into the file. We use scanf() function to read the data from the keyboard. And in file handling we use fscanf() to read the data from the file. This is called file manipulation.

The major difference between manipulation of file and terminal I/O is that the terminal I/O is standard no need to specify anything but it is necessary to specify files to be used in the programs where file I/O are performed. It is possible have many files on the disk. If you wish to use a file or files in the programs, then you must specify which file or files you wish to use. Specification of the file that is to be used is referred as opening a file.
At the time of opening the file it is also compulsory to specify the type of operation to be performed i.e. Read from the file, Write to the file, or both. This specification is done through the file opening mode. When different files are used in the program, it is required to specify a particular file for reading or writing. It can be done using a variable called a FILE pointer.

Every file you open has its own FILE pointer variable. When you wish to write to a fiie you specify the file by using its file pointer variable. The file pointer declared using FILE data type is called as logical file. The data is not stored permanently on the secondary storage with this name. It is stored with other file name which is called as physical file name. The logical file is linked with this physical file name. The read/write operations are done on logical file in the program which is indirectly transferred from or to the physical file. The linking of logical file with physical file is done through fopen() function. The FILE pointer variables can be declared as follows:

FILE *fP1, *fp2, *fp3;

The variables fpl, fp2, fp3 are the pointer variables of the type FILE or simply file pointers. They can store the address of any physical file.

Any name can be used as file pointer but must be a valid variable or identifier name of C language. The rules of standard data type identifiers apply to these variables also. The declared FILE Pointer variable may hold address of any physical file but only one at a time. So, at a given point of time logically a logical file points to one and only one physical file. The read / write operactions performed on the file pointer indirectly directed to physical file. At the time of opening file the file pointed by file pointer variable is mentioned along with the type of operation. The opened file is closed when the operation is finished or whenever a new file is to be attached. We will discuss file opening and closing in more details in the next article.
© Copyright 2013 Computer Programming | All Right Reserved