0% found this document useful (0 votes)
5 views14 pages

Java AWT Applet Examples

The document contains multiple Java applet and frame examples demonstrating the use of various GUI components such as buttons, labels, checkboxes, text fields, and lists. Each example includes code snippets for creating and displaying these components in a graphical user interface. The applets and frames utilize different layouts like GridLayout and FlowLayout to organize the components visually.

Uploaded by

Prashant Bhamare
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views14 pages

Java AWT Applet Examples

The document contains multiple Java applet and frame examples demonstrating the use of various GUI components such as buttons, labels, checkboxes, text fields, and lists. Each example includes code snippets for creating and displaying these components in a graphical user interface. The applets and frames utilize different layouts like GridLayout and FlowLayout to organize the components visually.

Uploaded by

Prashant Bhamare
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

*;

import [Link].*;

public class Buttons extends Applet

public void init()

Button o,r,c;

o = new Button("OK");

r = new Button("RESET");

c = new Button("CANCEL");

add(o);

add(r);

add(c);

/*<applet code="[Link]" width=500 height=300></applet>*/

Output :
import [Link].*;

import [Link].*;

public class LabelDemo extends Applet

public void init()

Label dis = new Label("Welcome to java");

add(dis);

/*<applet code="[Link]" width=500 height=300></applet>*/

Output :
import [Link].*;

import [Link].*;

public class Lang extends Applet

public void init()

Checkbox m,h,e,s;

m=new Checkbox("Marathi");

h=new Checkbox("Hindi");

e=new Checkbox("English");

s=new Checkbox("Sanskrit");

add(m);

add(h);

add(e);

add(s);

/*<applet code="[Link]" width=500 height=300></applet>*/

Output :
import [Link].*;

class Form extends Frame

Button b1,b2;

Label l1,l2,l3,l4;

TextField t1,t2,t3;

TextArea t;

Form()

setLayout(new GridLayout(5,2));

b1=new Button("Submit");

b2=new Button("Cancel");

l1=new Label("Full Name");

l2=new Label("Address");

l3=new Label("Phone no");

l4=new Label("Email Id");

t1=new TextField();

t2=new TextField();

t3=new TextField();

t=new TextArea();

add(l1);

add(t1);

add(l2);

add(t);

add(l3);

add(t2);

add(l4);

add(t3);

add(b1);

add(b2);
}

public static void main(String args[])

Form f=new Form();

[Link](300,400);

[Link](true);

Output :
import [Link].*;

public class Radio_Demo extends Frame

Label l1;

Radio_Demo()

setLayout(new FlowLayout());

l1=new Label("Gender"):

CheckboxGroup cbg=new CheckboxGroup();

Checkbox c1=new Checkbox("Male");

Checkbox c2=new Checkbox("Female");

add(l1);

add(c1);

add(c2)

public static void main(String args[])

Radio_Demo r=new Radio_Demo();

[Link](500,600);

[Link](true);

Output :
import [Link].*;

import [Link].*;

public class List_Demo extends Applet

public void init()

List l=new List();

[Link]("Summer");

[Link]("Winter");

[Link]("Rainy");

add(l);

/*<applet code="List_Demo.class" width=300 height=300></applet>*/

Output:
import [Link].*;

import [Link].*;

public class Cities extends Applet

public void init()

List l1=new List(10,true);

[Link]("Nashik");

[Link]("Pune");

[Link]("Mumbai");

[Link]("Nanded");

[Link]("Sinner");

[Link]("Jalgaon");

[Link]("Dhule");

[Link]("Ahmednagar");

[Link]("Nandurbar");

[Link]("Buldhana");

add(l1);

/*<applet code="[Link]" width=300 height=300></applet>*/

Output:
import [Link].*;

import [Link].*;

public class Newspaper extends Applet

public void init()

List l1=new List(10,true);

[Link]("The Indian Express");

[Link]("The Times Of India");

[Link]("Lokmat");

[Link]("Hindustan Times");

add(l1);

/*<applet code="[Link]" width=300 height=300></applet>*/

Output :
import [Link].*;

import [Link].*;

public class GridLayout_Demo1 extends Applet

GridLayout g;

Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9;

public void init()

g=new GridLayout(5,2);

setLayout(g);

b0=new Button("A");

b1=new Button("B");

b2=new Button("C");

b3=new Button("D");

b4=new Button("E");

b5=new Button("F");

b6=new Button("G");

b7=new Button("H");

b8=new Button("I");

b9=new Button("J");

add(b0);

add(b1);

add(b2);

add(b3);

add(b4);

add(b5);

add(b6);

add(b7);

add(b8);

add(b9);

}
}

/*<applet code="GridLayout_Demo1.class" width=300 height=300></applet>*/

Output :
import [Link];

import [Link];

import [Link];

import [Link];

public class SwingDemo

public static void main(String args[])

JFrame frame = new JFrame();

JPanel panel = new JPanel(new GridLayout(5,5,10,10));

for(int i=1;i<=25;i++)

[Link](new JLabel("Displaying label "+[Link](i)));

[Link](panel);

[Link](550,300);

[Link](true);

Output :
import [Link].*;

import [Link].*;

public class GridLayout_Demo extends Applet

GridLayout g;

Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9;

public void init()

g=new GridLayout(5,2);

setLayout(g);

b0=new Button("0");

b1=new Button("1");

b2=new Button("2");

b3=new Button("3");

b4=new Button("4");

b5=new Button("5");

b6=new Button("6");

b7=new Button("7");

b8=new Button("8");

b9=new Button("9");

add(b0);

add(b1);

add(b2);

add(b3);

add(b4);

add(b5);

add(b6);

add(b7);

add(b8);

add(b9);

}
}

/*<applet code="GridLayout_Demo.class" width=300 height=300></applet>*/

Output :

You might also like