Experiment 1

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 37

EXPERIMENT1

X_1

import java.awt.*;

public class ButtonTypeExample extends Frame

public static void main(String[] args)

Frame f = new Frame();

f.setTitle("Button Types");

f.setSize(400,400);

f.setVisible(true);

f.setLayout(new GridLayout(5,2));

Label l1 = new Label("Redio Button");

f.add(l1);

Label l2 = new Label("Gender");

f.add(l2);

CheckboxGroup cbg = new CheckboxGroup();

Checkbox box1 = new Checkbox("Male",cbg,false);

Checkbox box2 = new Checkbox("Female",cbg,true);

f.add(box1);

f.add(box2);
Label l3 = new Label("Check Box");

f.add(l3);

Label l4 = new Label("Select Programming Languages");

f.add(l4);

Checkbox Box1 = new Checkbox("C");

Checkbox Box2 = new Checkbox("C++");

Checkbox Box3 = new Checkbox("JAVA");

Checkbox Box4 = new Checkbox("Advance Java");

f.add(Box1);

f.add(Box2);

f.add(Box3);

f.add(Box4);

OUTPUT:
X_2

import java.awt.*;

public class Form extends Frame

public static void main(String[] args)

Frame f = new Frame();

f.setTitle("Student Login Form");

f.setSize(500,500);

f.setVisible(true);

f.setLayout(new FlowLayout(FlowLayout.CENTER));

Label la1 = new Label("Simple Example using AWT components",Label.LEFT);

f.add(la1);
Label la1 = new Label("Enter your First name",Label.LEFT);

la1.setBounds(40, 80, 20, 60);

f.add(la1);

TextField tf1 = new TextField(22);

tf1.setSize(10,5);

f.add(tf1);

Label l2 = new Label("Enter your Last name",Label.LEFT);

l2.setBounds(40, 120, 20, 60);

f.add(l2);

TextField tf2 = new TextField(22);

f.add(tf2);

Label l3 = new Label("Enter your gmail add:",Label.LEFT);

l3.setBounds(40, 120, 20, 60);

f.add(l3);

TextArea ta = new TextArea(3,22);

f.add(ta);

Label l4 = new Label("Gender",Label.LEFT);

l4.setBounds(40, 80, 320, 260);

f.add(l4);

CheckboxGroup cbg = new CheckboxGroup();

Checkbox cbox1 = new Checkbox("Male",cbg,true);


Checkbox cbox2 = new Checkbox("Female",cbg,false);

f.add(cbox1);

f.add(cbox2);

Label la3 = new Label("Select Programming Languages",Label.LEFT);

la3.setBounds(40, 80, 320, 260);

f.add(la3);

Checkbox Box1 = new Checkbox("M1");

Checkbox Box2 = new Checkbox("M2");

Checkbox Box3 = new Checkbox("JAVA");

Checkbox Box4 = new Checkbox("Data structure");

f.add(Box1);

f.add(Box2);

f.add(Box3);

f.add(Box4);

OUTPUT:
XIII_1

import java.awt.*;

Public class LableExample extends Frame

Public static void main(String args[])

Frame f=new Frame();

f.setTitle(“My Frame”);

f.setSize(400,400);

f.setVisible(true);

FlowLayout fl=new FlowLayout();

f.setLayout(fl);

Label l=new label(“Welcome to Java”);

l.setBounds(40,50,60,70);
f.add(l);

XIII_2

import java.awt.*;

Public class CheckboxExample extends Frame

Public static void main(String args[])

Frame f=new Frame();

f.setTitle(“My Frame”);

f.setSize(400,400);

f.setVisible(true);

FlowLayout fl=new FlowLayout();

f.setLayout(fl);

Checkbox ch1=new Checkbox(“Marathi”);

Checkbox ch2=new Checkbox(“Hindi”);

Checkbox ch3=new Checkbox(“English”);

Checkbox ch4=new Checkbox(“Sanskrit”);

f.add(ch1);

f.add(ch2);
f.add(ch3);

f.add(ch4);

XIII_3

import java.awt.*;

Public class ButtonExample extends Frame

Public static void main(String args[])

Frame f=new Frame();

f.setTitle(“My Frame”);

f.setSize(400,400);

f.setVisible(true);

FlowLayout fl=new FlowLayout();

f.setLayout(fl);

Button b1=new Button (“Ok”);

Button b2=new Button (“Reset”);

Button b3=new Button (“Cancel”);

f.add(b1);

f.add(b2);
f.add(b3);

X_2

import java.awt.*;

public class Form extends Frame

public static void main(String[] args)

Frame f = new Frame();

f.setTitle("Student Login Form");

f.setSize(500,500);

f.setVisible(true);

f.setLayout(new FlowLayout(FlowLayout.CENTER));

Label la1 = new Label("Simple Example using AWT components",Label.LEFT);

f.add(la1);

Label la1 = new Label("Enter your First name",Label.LEFT);

la1.setBounds(40, 80, 20, 60);

f.add(la1);

TextField tf1 = new TextField(22);

tf1.setSize(10,5);
f.add(tf1);

Label l2 = new Label("Enter your Last name",Label.LEFT);

l2.setBounds(40, 120, 20, 60);

f.add(l2);

TextField tf2 = new TextField(22);

f.add(tf2);

Label l3 = new Label("Enter your gmail add:",Label.LEFT);

l3.setBounds(40, 120, 20, 60);

f.add(l3);

TextArea ta = new TextArea(3,22);

f.add(ta);

Label l4 = new Label("Gender",Label.LEFT);

l4.setBounds(40, 80, 320, 260);

f.add(l4);

CheckboxGroup cbg = new CheckboxGroup();

Checkbox cbox1 = new Checkbox("Male",cbg,true);

Checkbox cbox2 = new Checkbox("Female",cbg,false);

f.add(cbox1);

f.add(cbox2);

Label la3 = new Label("Select Programming Languages",Label.LEFT);

la3.setBounds(40, 80, 320, 260);


f.add(la3);

Checkbox Box1 = new Checkbox("M1");

Checkbox Box2 = new Checkbox("M2");

Checkbox Box3 = new Checkbox("JAVA");

Checkbox Box4 = new Checkbox("Data structure");

f.add(Box1);

f.add(Box2);

f.add(Box3);

f.add(Box4);

OUTPUT:

XIII_1

import java.awt.*;
Public class LableExample extends Frame

Public static void main(String args[])

Frame f=new Frame();

f.setTitle(“My Frame”);

f.setSize(400,400);

f.setVisible(true);

FlowLayout fl=new FlowLayout();

f.setLayout(fl);

Label l=new label(“Welcome to Java”);

l.setBounds(40,50,60,70);

f.add(l);

XIII_2

import java.awt.*;

Public class CheckboxExample extends Frame

Public static void main(String args[])

{
Frame f=new Frame();

f.setTitle(“My Frame”);

f.setSize(400,400);

f.setVisible(true);

FlowLayout fl=new FlowLayout();

f.setLayout(fl);

Checkbox ch1=new Checkbox(“Marathi”);

Checkbox ch2=new Checkbox(“Hindi”);

Checkbox ch3=new Checkbox(“English”);

Checkbox ch4=new Checkbox(“Sanskrit”);

f.add(ch1);

f.add(ch2);

f.add(ch3);

f.add(ch4);

XIII_3

import java.awt.*;

Public class ButtonExample extends Frame

Public static void main(String args[])


{

Frame f=new Frame();

f.setTitle(“My Frame”);

f.setSize(400,400);

f.setVisible(true);

FlowLayout fl=new FlowLayout();

f.setLayout(fl);

Button b1=new Button (“Ok”);

Button b2=new Button (“Reset”);

Button b3=new Button (“Cancel”);

f.add(b1);

f.add(b2);

f.add(b3);

}
EXPERIMENT_2

import java.awt.*;

import java.applet.*;

public class AppletExample extends Applet

Public void init()

List l=new List();

l.add(“Summer”);

l.add(“Summer”);

l.add(“Winter”);

l.add(“Rainy”);

}
XIII_1

import java.applet.*;

import java.awt.*;

public class City extends Applet

public void init()

Label la1 = new Label("List Of Cities");

add(la1);

List l1 = new List();

l1.add("Pune");

l1.add("Mumbai");

l1.add("Satara");

l1.add("Kanpur");

l1.add("Rajkot");

l1.add("Delhi");

l1.add("Chennai");

l1.add("Nagpur");

l1.add("Shevgoan");
l1.add("Indore");

add(l1);

/*<applet code=”City” height=300 width=300>*/

XIII_2

import java.applet.*;

import java.awt.*;

public class NewsPaper extends Applet

public void init()

Label la1 = new Label("List Of NewsPaper");

add(la1);

List l1 = new List(5, true);

l1.add("Maharastra Times");

l1.add("Sakal");

l1.add("The Hindu");

l1.add("Lokmat");
l1.add("Pudhari");

l1.add("The Times Of India");

l1.add("The Indian Express");

l1.add("Loksatta");

add(l1);

/*<applet code=” NewsPaper” height=300 width=300>*/


EXPERIMENT3I

import java.awt.Button;

import java.awt.Frame;

import java.awt.GridLayout;

import java.io.Serializable;

public class Experiment3XIII1 extends Frame

public static void main(String[] args)

Frame f= new Frame();

f.setTitle("GridLayout Dem0");

f.setSize(425,350);

f.setVisible(true);

f.setLayout(new GridLayout(4,3,10,10));

Button button1 = new Button("Button 1");


Button button2 = new Button("Button 2");

Button button3 = new Button("Button 3");

Button button4 = new Button("Button 4");

Button button5 = new Button("Button 5");

f.add(button1);

f.add(button2);

f.add(button3);

f.add(button4);

f.add(button5);

EXPERIMENT3II

XIII.1:
import java.awt.*;

public class Experiment3XIII1 extends Frame


{
public static void main(String[] args)
{
Frame f= new Frame();

f.setTitle("GridLayout Dem0");
f.setSize(425,350);
f.setVisible(true);

f.setLayout(new GridLayout(4,3,10,10));

Button button1 = new Button("Button 1");


Button button2 = new Button("Button 2");
Button button3 = new Button("Button 3");

Button button4 = new Button("Button 4");


Button button5 = new Button("Button 5");

f.add(button1);
f.add(button2);
f.add(button3);
f.add(button4);
f.add(button5);

}
}
EXPERIMENT_3

Ex1:
import java.awt.*;

public class Grid1 extends Frame


{
public static void main(String[] args)
{
Frame f = new Frame();

f.setTitle("Grid 5*5");
f.setSize(400,400);
f.setVisible(true);
f.setLayout(new GridLayout(5,5));

Button button1 = new Button("C");


Button button2 = new Button("C++");
Button button3 = new Button("Java");
Button button4 = new Button("AdvanceJava");
Button button5 = new Button("C#");

Button button6 = new Button("DSU");


Button button7 = new Button("OS");
Button button8 = new Button("CGR");
Button button9 = new Button("HTML");
Button button10 = new Button("CPH");

Button button11 = new Button("JAVAScript");


Button button12 = new Button("JSB");
Button button13 = new Button("Hibernate");
Button button14 = new Button("Spring");
Button button15 = new Button("Hadoop");

Button button16 = new Button("Phython");


Button button17 = new Button("Data Base");
Button button18 = new Button("RDBMS");
Button button19 = new Button("MIC");
Button button20 = new Button("Assembly");
Button button21 = new Button("PHP");
Button button22 = new Button("IOT");
Button button23 = new Button("Kotlin");
Button button24 = new Button("SQL");
Button button25 = new Button("Rust");

f.add(button1);
f.add(button2);
f.add(button3);
f.add(button4);
f.add(button5);

f.add(button6);
f.add(button7);
f.add(button8);
f.add(button9);
f.add(button10);

f.add(button11);
f.add(button12);
f.add(button13);
f.add(button14);
f.add(button15);

f.add(button16);
f.add(button17);
f.add(button18);
f.add(button19);
f.add(button20);

f.add(button21);
f.add(button22);
f.add(button23);
f.add(button24);
f.add(button25);
}
}

OUTPUT :
EX2:
import java.awt.*;
public class Grid2 extends Frame
{
public static void main(String[] args)
{
Frame f = new Frame();

f.setTitle("Grid 5*5");
f.setSize(450,450);
f.setVisible(true);

f.setLayout(new GridLayout(5,5,8,10));
Button button1 = new Button("C");
Button button2 = new Button("C++");
Button button3 = new Button("Java");
Button button4 = new Button("AdvanceJava");
Button button5 = new Button("C#");

Button button6 = new Button("DSU");


Button button7 = new Button("OS");
Button button8 = new Button("CGR");
Button button9 = new Button("HTML");
Button button10 = new Button("CPH");

Button button11 = new Button("JAVAScript");


Button button12 = new Button("JSB");
Button button13 = new Button("Hibernate");
Button button14 = new Button("Spring");
Button button15 = new Button("Hadoop");

Button button16 = new Button("Phython");


Button button17 = new Button("Data Base");
Button button18 = new Button("RDBMS");
Button button19 = new Button("MIC");
Button button20 = new Button("Assembly");

Button button21 = new Button("PHP");


Button button22 = new Button("IOT");
Button button23 = new Button("Kotlin");
Button button24 = new Button("SQL");
Button button25 = new Button("Rust");
f.add(button1);
f.add(button2);
f.add(button3);
f.add(button4);
f.add(button5);

f.add(button6);
f.add(button7);
f.add(button8);
f.add(button9);
f.add(button10);

f.add(button11);
f.add(button12);
f.add(button13);
f.add(button14);
f.add(button15);

f.add(button16);
f.add(button17);
f.add(button18);
f.add(button19);
f.add(button20);

f.add(button21);
f.add(button22);
f.add(button23);
f.add(button24);
f.add(button25);
}
}
OUTPUT :

EXPERIMENT 3.XIII.2:

import java.awt.*;
public class Experiment3XIII2 extends Frame
{
public static void main(String[] args)
{
Frame f= new Frame();

f.setTitle("Student Login Form");


f.setSize(300,300);
f.setVisible(true);
f.setLayout(new BorderLayout());
Button button1 = new Button("North");
f.add(button1,BorderLayout.NORTH);

Button button2 = new Button("West");


f.add(button2,BorderLayout.WEST);

Button button3 = new Button("South");


f.add(button3,BorderLayout.SOUTH);

Button button4 = new Button("East");


f.add(button4,BorderLayout.EAST);

Button button5 = new Button("center");


f.add(button5,BorderLayout.CENTER);
}
}
OUTPUT :
EXPERIMENT_4

import java.awt.*;
public class Experiment4II extends Frame
{

public static void main(String[] args)


{
Frame f = new Frame();

f.setTitle("Grid 5*5");
f.setSize(350,350);
f.setVisible(true);

GridBagLayout gbl = new GridBagLayout();


Label l1 = new Label("Name");
l1.setBounds(40, 80, 120, 160);

EXPERIMENT_5XI
import java.awt.*;

public class Experiment5XI extends Frame


{

public static void main(String[] args)


{
Frame f = new Frame();
f.setTitle("MenuBar Demo");
f.setSize(350,350);
f.setLayout(new FlowLayout());
f.setVisible(true);

MenuBar mb= new MenuBar();


/*mb.setBackground(Color.blue);*/

Menu mn1=new Menu("File");


mn1.setBackground(Color.blue);

MenuItem m1=new MenuItem("New..");


MenuItem m2=new MenuItem("open..");
MenuItem m3=new MenuItem("Save as..");
MenuItem m4=new MenuItem("Exit");
mn1.add(m1);
mn1.add(m2);
mn1.add(m3);
mn1.add(m4);

Menu mn2=new Menu("Edit");


MenuItem mI1=new MenuItem("Undo..");
MenuItem mI2=new MenuItem("Cut..");
MenuItem mI3=new MenuItem("Copy..");
MenuItem mI4=new MenuItem("Paste");
MenuItem mI5=new MenuItem("Delete");
mn2.add(mI1);
mn2.add(mI2);
mn2.add(mI3);
mn2.add(mI4);
mn2.add(mI5);

Menu mn3=new Menu("Format");


MenuItem mII1=new MenuItem("Word Wrap.");
MenuItem mII2=new MenuItem("font");
mn3.add(mII1);
mn3.add(mII2);

Menu mn4=new Menu("view");


MenuItem mIII1=new MenuItem("Status Bar");
mn4.add(mIII1);

Menu mn5=new Menu("Help");


MenuItem mIV1=new MenuItem("View Help");
MenuItem mIV2=new MenuItem("About Notepad");
mn5.add(mIV1);
mn5.add(mIV2);

mb.add(mn1);
mb.add(mn2);
mb.add(mn3);
mb.add(mn4);
mb.add(mn5);

f.setJMenuBar(mb);
}
}

EXPERIMENT5XIII1(page no.28)

import java.awt*;
public class Experiment5XIII1 extends Frame
{

MenuBar mb;
MenuItem m1,m2,m3,m4;
Menu mn;
MenuShortcut ms;

Experiment5XIII1()
{
setTitle("MenuBar Demo");
setSize(500,500);
setLayout(null);

ms=new MenuShortcut(KeyEvent.VK_1);
mn=new Menu("File");

mb= new MenuBar();


m1=new MenuItem("New..");
m2=new MenuItem("open..");
m3=new MenuItem("Save as..");
m4=new MenuItem("Exit",ms);

mn.add(m1);
mn.add(m2);
mn.add(m3);
mn.addSeparator();
mn.add(m4);
mb.add(mn);

}
public static void main(String[] args)
{

Experiment5XIII1 experiment5XIII1 = new Experiment5XIII1();


experiment5XIII1.setVisible(true);
}

}
 PROGRAM FOR NOTEPAD
import java.awt.*;

public class Experiment5XI extends Frame


{
public static void main(String[] args)
{
Frame f = new Frame();
f.setTitle("MenuBar Demo");
f.setSize(500,500);
f.setLayout(new FlowLayout());
f.setVisible(true);

MenuBar mb= new MenuBar();


Menu mn1=new Menu("File");
mn1.setBackground(Color.blue);

MenuItem m1=new MenuItem("New..");


MenuItem m2=new MenuItem("open..");
MenuItem m3=new MenuItem("Save as..");
MenuItem m4=new MenuItem("Exit");
mn1.add(m1);
mn1.add(m2);
mn1.add(m3);
mn1.add(m4);

Menu mn2=new Menu("Edit");


MenuItem mI1=new MenuItem("Undo..");
MenuItem mI2=new MenuItem("Cut..");
MenuItem mI3=new MenuItem("Copy..");
MenuItem mI4=new MenuItem("Paste");
MenuItem mI5=new MenuItem("Delete");
mn2.add(mI1);
mn2.add(mI2);
mn2.add(mI3);
mn2.add(mI4);
mn2.add(mI5);

Menu mn3=new Menu("Format");


MenuItem mII1=new MenuItem("Word Wrap.");
MenuItem mII2=new MenuItem("font");
mn3.add(mII1);
mn3.add(mII2);

Menu mn4=new Menu("view");


MenuItem mIII1=new MenuItem("Status Bar");
mn4.add(mIII1);

Menu mn5=new Menu("Help");


MenuItem mIV1=new MenuItem("View Help");
MenuItem mIV2=new MenuItem("About Notepad");
mn5.add(mIV1);
mn5.add(mIV2);

mb.add(mn1);
mb.add(mn2);
mb.add(mn3);
mb.add(mn4);
mb.add(mn5);

f.setMenuBar(mb);
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy