Java Applet
Applets- Applets are small Java programs that are primerly used on internet computing. They can be transferred over the internet from one and run using the applet viewer or any web browser that supports Java. An applet like any application program can do anything for us. It can perform arithmetic operator, display, graphics, play sounds , Accept the user input create animation and play interactive games.
How applets viewers Differs Java application- Alto bahut applets and stand alone application are Java programs that there are some difference between them. Applets are not full feature application program they are usually written to small task. since, they are usually designed for use on the internet they impose certain limitation and restriction their design.
preparing to write applets- the steps involved to developing and testing applet are-
1- building an applet code.
2- creating an executable applets.
3- designing webpage using HTML tags.
4- preparing applet tag.
5- testing the applet code.
Example-:
1-
Import Java. awt.*;
import java. applet.*;
public class hello java extends Applet
{
g. drawstring ("Hello java",50,150,);
}
}
2-
<HTML>
<Head>
</Head>
<Body>
<Applet code=hello java.class Height=300 width=300>
</Applet>
</Body>
</HTML>
GUI Components
Graphical user interface is used to accept input a user friendly manner. A graphical user interface variable from application to application and may consists of text boxes , level , list boxes and other such elements different programming languages provide different ways and means to create graphical user interface. A a graphical user interface elements is generally created using the following procedure-
1- create the elements.
2- determined initial appearance.
3- decide whether it should occupy specific position or maybe position.
4- add it to screen interface.
AWT-(Abstract window Toolkit)-
abstract window toolkit is a set of Java classes that allows us to create a graphical user interface and accept user input through the keyboard and mouse. Abstract window toolkit provide us with various items which enable creation of an attractive and efficient graphical user interface.
Containers- A container is an area that can hold elements can be drawn or painted.
there is a class named container in Java. abstract window toolkit packages which directly or indirectly derived into commonly used container frames and panel.
Frame- a frame is a window that is independent of an applet and of the browser. it can either act as a container or as a component. it can be created using one of the following constructor-(a) Frame ()
(b) Frame ( string title)
Examples-
Import java.awt.*;
class framedemo extends Frame
{
Public framedemo (string title)
{
Super (title);
}
Public static void main (string args[])
{
Framedemo f=new framedemo ("this is the frame");
f.setsize(500,500);
f.setvisible(true);
}
}
Panel- panels are containers used to group a number of components together. The simplest way of creating a panel is through is constructor panels.
Example-
Import java.awt.*;
class paneltest extends panel
{
Public static void main (string args[])
{
Paneltest p=new paneltest ();
Frame f= new frame("Testing a panel");
f.add(p);
f.setsize(500,500);
f.setvisible(true);
}
}
No comments:
Post a Comment