Q:Question 2: Using FlowLayout Manager, write a program that meets the following requirements (see figure below)• Create a frame and set its layout to FlowLayout • Create 2 panels and add them to the frame. • Each panel contains three buttons. The panel uses FlowLayout.
Q:Question 2: Using FlowLayout Manager, write a program that meets the following requirements (see figure below):
• Create a frame and set its layout to FlowLayout
• Create 2 panels and add them to the frame.
• Each panel contains three buttons. The panel uses FlowLayout.
Code :
import javax.swing.*;
import java.awt.*;
import java.awt.FlowLayout;
class swingex
{
public static void main (String args[])
{
JFrame f = new JFrame ();
JPanel p1 =new JPanel();
JPanel p2 =new JPanel();
p1.setBounds(100,100,150,150);
p2.setBounds(300,100,150,150);
JButton b1 = new JButton ("welcome");
JButton b2 = new JButton ("hello");
JButton b3 = new JButton ("open");
JButton b4 = new JButton ("click");
JButton b5 = new JButton ("done");
JButton b6 = new JButton ("ok");
b1.setBounds(50,10,50,50);
b2.setBounds(50,60,50,50);
b3.setBounds(50,80,50,50);
b4.setBounds(50,70,50,50);
b5.setBounds(50,90,50,50);
b6.setBounds(50,50,50,50);
p1.add(b1);
p1.add(b2);
p1.add(b3);
p2.add(b4);
p2.add(b5);
p2.add(b6);
f.add(p1);
f.add(p2);
f.setSize(400,200);
f.setLayout(new FlowLayout());
f.setVisible(true);
}
project of pdf on showing consumption and conservation of resources in your locality
ReplyDeletethank you from vibhansu tyagi side
ReplyDelete