0% found this document useful (0 votes)
2 views4 pages

Practical Java 3

The document contains multiple Java programs that create GUI frames using the AWT library. Each program demonstrates different layouts, including GridLayout and BorderLayout, and adds buttons to the frames. The programs showcase various configurations for button placement and frame visibility.
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)
2 views4 pages

Practical Java 3

The document contains multiple Java programs that create GUI frames using the AWT library. Each program demonstrates different layouts, including GridLayout and BorderLayout, and adds buttons to the frames. The programs showcase various configurations for button placement and frame visibility.
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

Program 2

import java.awt.*;
public class Program
{
Program()
{
Frame f = new Frame();
f.setSize(100,200);
f.setVisible(true);
f.setLayout(new GridLayout(5,3));
int b=0;
for(int i=0;i<10;i++)
{
f.add(new Button("Button"+b));
b++;
}
}
public static void main(String[] args)
{
Program g = new Program();
}
}

OUTPUT
Program 1
import java.awt.*;
public class Pg
{
Pg()
{
Frame f= new Frame();
int b=1;
for(int i=0;i<5;i++)
{
for(int j=0;j<5;j++)
{
f.add(new Button ("Button"+b));
b++;
}
}
f.setVisible(true);
f.setLayout(new GridLayout(5,5));
f.setSize(200,200);}
public static void main (String args[])
{
Pg p = new Pg();
}
}
OUTPUT
import java.awt.*;
public class Pr
{
Pr()
{
Frame f = new Frame();
Button b =new Button("Button1");
f.add(b);
Button b1 =new Button("Button2");
f.add(b1);
Button b2 =new Button("Button3");
f.add(b2);
Button b3 =new Button("Button4");
f.add(b3);
Button b4 =new Button("Button5");
f.add(b4);
f.setLayout(new GridLayout(3,0,6,6));
f.setSize(200,200);
f.setVisible(true);
}
public static void main(String[] args)
{
Pr p = new Pr();
}
}

OUTPUT
PROGRAM
import java.awt.*;
public class Border
{
Border()
{
Frame f = new Frame();
Button b1=new Button(BorderLayout.NORTH);
Button b2=new Button(BorderLayout.SOUTH);
Button b3=new Button(BorderLayout.EAST);
Button b4=new Button(BorderLayout.WEST);
Button b5=new Button(BorderLayout.CENTER);
f.add(b1,BorderLayout.NORTH);
f.add(b2,BorderLayout.SOUTH);
f.add(b3,BorderLayout.EAST);
f.add(b4,BorderLayout.WEST);
f.add(b5,BorderLayout.CENTER);
f.setSize(200,200);
f.setVisible(true);
}
public static void main (String args [])
{
Border d = new Border();
}
}
OUTPUT

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