0% found this document useful (0 votes)
1K views4 pages

Experiment No. 1: 1) Develop A Program Using Label To Display Message "Welcome To Java" Program Code:-Output

The document describes 4 experiments involving Java GUI programming. Experiment 1 involves creating simple GUI elements like labels, lists, buttons using Swing components. Experiment 2 focuses on creating frames and applets, and adding components like labels and lists. Experiment 3 designs a bio-data applet using various Swing components like text fields, text areas, labels, radio buttons, checkboxes to collect user details. Experiment 4 (not shown) likely involves more advanced GUI programming concepts. The experiments provide examples of basic to more complex Swing programming.
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)
1K views4 pages

Experiment No. 1: 1) Develop A Program Using Label To Display Message "Welcome To Java" Program Code:-Output

The document describes 4 experiments involving Java GUI programming. Experiment 1 involves creating simple GUI elements like labels, lists, buttons using Swing components. Experiment 2 focuses on creating frames and applets, and adding components like labels and lists. Experiment 3 designs a bio-data applet using various Swing components like text fields, text areas, labels, radio buttons, checkboxes to collect user details. Experiment 4 (not shown) likely involves more advanced GUI programming concepts. The experiments provide examples of basic to more complex Swing programming.
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/ 4

EXPERIMENT NO.

1
1) Develop a program using Label to display message “Welcome to Java”

Program Code :- Output :-


import java.awt.*;
public class Ex1_3 extends Frame
{
public static void main (String args[])
{
Ex1_3 f= new Ex1_3();
f.setTitle("Title");
f.setVisible(true);
f.setSize(500,500);
f.setLayout(new FlowLayout());
Label l1,l2,l3;

l1=new Label();
l1.setText("Welcome to Java");
l1.setAlignment(Label.CENTER);

f.add(l1);
}
}

2) Develop a program to select multiple languages known to user. (e. g. Marathi, Hindi, English, Sanskrit).

Program Code :- Output :-


import java.applet.Applet;
import java.awt.*;

/* <applet code="Ex1_4_app.class" width="300"


height="300">
</applet> */

public class Ex1_4_app extends Applet


{
public void init()
{
List li3;
Label l;
l=new Label();
li3=new List(3,true);
l.setText("Select Multiple Languages : ");
add(l);
li3.add("Marathi");
li3.add("Hindi",1);
li3.add("English",2);
li3.add("Sanskrit",3);
add(li3);
}
}
3) Write a program to create three Buttons with Caption OK, RESET and CANCEL.

Program Code :- Output :-


import java.applet.Applet;
import java.awt.*;

/* <applet code="Ex1_4_app.class" width="300"


height="300">
</applet> */

public class Ex1_4_app extends Applet


{
public void init()
{
Button b1,b2,b3;
b1=new Button();
b1.setLabel("OK");
add(b1);
b2=new Button("RESET");
add(b2);
b3=new Button("CANCEL");
add(b3);
}
}

4) Develop a program to illustrate the use of scrollbars.

Program Code :- Output :-

import java.awt.*;
import java.applet.*;
/* <applet code=sc.class height=500 width=400>
</applet> */
public class sc extends Applet
{
Scrollbar scroll1,scroll2;
public void init()
{
scroll1=new
Scrollbar(Scrollbar.HORIZONTAL,1,20,1,200);
add(scroll1);
scroll2=new Scrollbar(Scrollbar.VERTICAL,1,20,1,200);
add(scroll2);
}
}
EXPERIMENT NO. 2
1) Develop a program to create Frame Window by a. Instantiating Frame class b. extending Frame class

(a) (b)
Program Code:- Program Code:-

import java.awt.*; import java.awt.*;

class Frame1 class Frame1 extends Frame


{ {
public static void main(String args[])
{ Frame1()
Label l=new Label("Frame Demo"); {
Label l=new Label("Frame Demo");
Frame f=new Frame(); add(l);
f.setVisible(true); setVisible(true);
f.setSize(400,300); setSize(200,200);
}
f.add(l);
} public static void main(String args[])
} {

Frame1 f=new Frame1();

}
}

2) Develop a Applet /Application to select multiple names of newspapers.

Program Code :- Output :-


import java.applet.Applet;
import java.awt.*;

/* <applet code="Ex2_3.class" width="300"


height="300">
</applet> */

public class Ex2_3 extends Applet


{
public void init()
{
List li2;
li2=new List(5,true);
li2.add("Times Of India");
li2.add("Lokmat",1);
li2.add("Pudhari",2);
li2.add("Punya Nagari",2);
li2.add("Indian Express",2);
add(li2);
}
}
3) Design an applet to create bio data using following components:

Button,choice,list,textfield,textarea,label,radiobutton etc.

Program Code :-
import java.applet.*; Label l3;
import java.awt.*; l3=new Label("Languages :- ");
l3.setBounds(20,220,70,50);
/* <applet code="Form.class" width="500" add(l3);
height="500">
</applet> */ List li3;
li3=new List(3,true);
public class Form extends Applet li3.add("Marathi");
{ li3.add("Hindi",1);
public void init() li3.add("English",2);
{ li3.add("Sanskrit",3);
setLayout(null); li3.setBounds(135,235,70,70);
Label l; add(li3);
l=new Label("Name :- ");
l.setBounds(20,20,50,50); Label l4;
add(l); l4=new Label("Age :- ");
l4.setBounds(20,305,50,50);
TextField t1; add(l4);
t1=new TextField();
t1.setBounds(135,35,200,35); Choice ch2;
add(t1); ch2=new Choice();
ch2.add("16");
Label l1; ch2.add("17");
l1=new Label("Address :- "); ch2.add("18");
l1.setBounds(20,90,50,50); ch2.add("19");
add(l1); ch2.add("20");
ch2.add("21");
TextArea t2; ch2.add("22");
t2=new TextArea(); ch2.setBounds(135,310,70,70);
t2.setBounds(135,105,200,75); add(ch2);
add(t2);
Button b1;
Label l2; b1=new Button("Submit");
l2=new Label("Gender :- "); b1.setBounds(65,360,70,40);
l2.setBounds(20,180,50,50); add(b1);
add(l2); }
}
Checkbox chb1,chb2;
CheckboxGroup cb1;
cb1=new CheckboxGroup();
chb1=new
Checkbox("Male",false,cb1);
chb1.setBounds(135,180,50,50);
add(chb1);
chb2=new
Checkbox("Female",cb1,true);
chb2.setBounds(285,180,70,50);
add(chb2);

You might also like