0% found this document useful (0 votes)
15 views2 pages

Practical 1

The document contains multiple Java applet programs demonstrating various GUI components. It includes examples of using labels, checkboxes, buttons, and text fields to create interactive user interfaces. Each program is designed to showcase specific functionalities such as displaying messages, selecting multiple languages, and gathering user input.

Uploaded by

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

Practical 1

The document contains multiple Java applet programs demonstrating various GUI components. It includes examples of using labels, checkboxes, buttons, and text fields to create interactive user interfaces. Each program is designed to showcase specific functionalities such as displaying messages, selecting multiple languages, and gathering user input.

Uploaded by

sanskaruravane9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Develop a program using Label to display message welcome to java

import java.awt.*;
import java.applet.*;
public class LabelDemo extends Applet {
public void init() {
Label one = new Label("Welcome to java Programming",Label.RIGHT);
Label two = new Label("Welcome to java Programming",Label.LEFT);

// add labels to applet window


add(one);
add(two);
}
}
/* <applet code="LabelDemo" width=300 height=200> </applet> */

2.Develop a program to select multiple languages known to user

// Demonstrate check boxes and radio button.


import java.awt.*;
import java.applet.*;
public class CheckboxDemo extends Applet
{
public void init()
{

Checkbox c1 = new Checkbox("Marathi");


Checkbox c2 = new Checkbox("Hindi");
Checkbox c3 = new Checkbox("English");
Checkbox c4 = new Checkbox("Sanskrit");
add(c1);
add(c2);
add(c3);
add(c4);
}
}
/* <applet code="CheckboxDemo" width=250 height=200> </applet> */

3.Develop a program to create three buttons with captions

// Demonstrate Buttons
import java.awt.*;
import java.applet.*;
public class ButtonDemo extends Applet
{
public void init()
{
Button b1 = new Button("Ok");
Button b2 = new Button("Reset");
Button b3 = new Button("Cancal");
add(b1);
add(b2);
add(b3);
}
}
/*<applet code="ButtonDemo" width=250 height=150> </applet> */
4. Design an applet to demonstrate the use of Radio Button and checkbox

// Demonstrate check boxes and radio button.


import java.awt.*;
import java.applet.*;
public class CheckboxDemo2 extends Applet
{
public void init()
{
Button yes = new Button("Yes");
Button no = new Button("No");
Button maybe = new Button("Undecided");
add(yes);
add(no);
add(maybe);
Checkbox c1 = new Checkbox("Practical 1");
Checkbox c1 = new Checkbox("Practical 2");
add(c1);
add(c2);
}
}
/* <applet code="CheckboxDemo" width=250 height=200> </applet> */

5. Design an applet to demonstrate the use of Text Field, Text Area, Button and
Label

import java.awt.*;
import java.applet.*;
public class TextFieldDemo extends Applet
{
TextField name, pass;
public void init()
{
Button b1=new Button("Inormation");
Label name = new Label("Name: ", Label.RIGHT);
Label pass = new Label("Password: ", Label.RIGHT);
Label addr = new Label("Address: ", Label.RIGHT);
name = new TextField(12);
pass = new TextField(8);
addr=new TextArea(4,4);
add(b1);
add(name);
add(pass);
add(addr);
}
}
/* <applet code="TextFieldDemo" width=380 height=150> </applet> */

You might also like