0% found this document useful (0 votes)
11 views5 pages

Practical No 1

This document contains code for 4 Java applets that demonstrate different GUI components: 1) Formdemo creates a simple form with labels, text fields, checkboxes, and buttons laid out in a grid. 2) Checkboxdemo displays multiple checkboxes positioned absolutely on the frame. 3) LabelDemo positions labels absolutely on the frame demonstrating the different alignment options. 4) Pgm2 lays out buttons in a flow layout to demonstrate the button component.

Uploaded by

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

Practical No 1

This document contains code for 4 Java applets that demonstrate different GUI components: 1) Formdemo creates a simple form with labels, text fields, checkboxes, and buttons laid out in a grid. 2) Checkboxdemo displays multiple checkboxes positioned absolutely on the frame. 3) LabelDemo positions labels absolutely on the frame demonstrating the different alignment options. 4) Pgm2 lays out buttons in a flow layout to demonstrate the button component.

Uploaded by

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

Practical No 1.

1
import java.applet.*;

import java.awt.*;

import static java.awt.TextArea.SCROLLBARS_BOTH;

class Formdemo extends Frame

Label lb1,lb2;

TextField txt1;

TextArea t1;

Checkbox cb1,cb2,cb3,cb4,cb5,cb6;

Button btn1;

CheckboxGroup cbg= new CheckboxGroup();

Formdemo()

lb1= new Label("Name:");

lb2= new Label("Address:");

txt1= new TextField();

t1= new TextArea();

cb1=new Checkbox("Computer");

cb2=new Checkbox("CIVIL");

cb3=new Checkbox("ELEC");

cb4=new Checkbox("MECH");

cbg= new CheckboxGroup();

cb5=new Checkbox("10th",false,cbg);

cb6=new Checkbox("12th",false,cbg);

btn1 = new Button("Submit");

setLayout(new GridLayout(10,10));

add(lb1); add(txt1); add(lb2); add(t1);

add(cb1); add(cb2); add(cb3);

add(cb4);
add(cb5); add(cb6);

add(btn1);

public static void main(String args[])

Formdemo fdo = new Formdemo();

fdo.setVisible(true); fdo.setSize(500,500);

fdo.setTitle("Formdemo");

}
Practical No 1.2
import java.awt.*; public class

Checkboxdemo extends Frame

Checkbox cb1,cb2,cb3,cb4;

String msg="";

Checkboxdemo()

setLayout(null);

setVisible(true);

setSize(500,500);

setTitle("Multiple Language");

cb1 = new Checkbox("Hi",false);

cb1.setBounds(100,100,50,50);

add(cb1);

cb2 = new Checkbox("Hello",false);

cb2.setBounds(100,200,50,50);

add(cb2); cb3 = new

Checkbox("By",false);

cb3.setBounds(100,300,50,50);

add(cb3);

public static void main(String[] args)

Checkboxdemo pg = new Checkboxdemo();

}
Practical 1.3
import java.awt.*;

class LabelDemo extends Frame

LableDemo()

//FlowLayout f1=new FlowLayout();

setLayout(null);

Label L1=new Label("India",Label.LEFT);

Label L2=new Label("America",Label.CENTER);

Label L3=new Label("Pune",Label.RIGHT);

L1.setBounds(100,200,100,80);

L2.setBounds(100,300,100,80);

L3.setBounds(100,400,100,80);

add(L1);

add(L2);

add(L3);

public static void main(String args[])

LabelDemo f1=new LabelDemo();

f1.setVisible(true);

f1.setSize(500,500);

f1.setTitle("Label Demo");

}
Practical 1.4
import java.awt.*; class

Pgm2 extends Frame

Button b1,b2,b3;

Pgm2()

setLayout(new FlowLayout());

setVisible(true);

setSize(300,300); b1=new

Button("ok"); b2=new

Button("reset"); b3=new

Button("cancel");

add(b1); add(b2);

add(b3);

public static void main(String args[])

Pgm2 pg = new Pgm2();

}
}

You might also like