0% found this document useful (0 votes)
4 views3 pages

Exp 1

Uploaded by

shahmeet644
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)
4 views3 pages

Exp 1

Uploaded by

shahmeet644
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
You are on page 1/ 3

`

EXPERIMENT NO 1
Q1)Develop a program using label to display message “WELCOME TO JAVA”.

import java.applet.Applet;
import java.awt.*;
public class NewApplet4 extends Applet
{
Label l;
public void init()
{
Label l = new Label ("WELCOME TO JAVA");
add(l);
}
}
OUTPUT :

Q2)Develop a program to select multiple languages know to user (Marathi ,Hindi ,English ,Sanskrit)

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class NewApplet extends Applet implements ItemListener {
String msg= " ";
Checkbox c1,c2,c3,c4;
public void init() {
c1 = new Checkbox ("MARATHI");
c2 = new Checkbox ("ENGLISH");
c3 = new Checkbox ("HINDI");
`

c4 = new Checkbox ("SANSKRIT");


add(c1);add(c2); add(c3); add(c4);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
c4.addItemListener(this);
}
public void itemStateChanged (ItemEvent ie)
{
if(c1.getState()==true )//&& c2.getState()==false && c3.getState()==false && c4.getState()==false)
msg = c1.getLabel();
if(c2.getState()==true)
msg = c2.getLabel();
if(c3.getState()==true)
msg = c3.getLabel();
if(c4.getState()==true)
msg = c4.getLabel();
repaint();
}
public void paint(Graphics g)
{
g.drawString("You have selected "+msg ,100,100);
}
OUTPUT :
`

3) Write a program to create three buttons with captions (OK, Cancel , Reset).

import java.applet.Applet;
import java.awt.*;
public class NewApplet3 extends Applet {
Button b1,b2,b3;
public void init() {
b1 = new Button("OK");
b2 = new Button("CANCEL");
b3 = new Button("RESET");
add(b1); add(b2); add(b3);
}
}
OUTPUT :

You might also like