import java.awt.*;
import java.awt.event.*;
class wh extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.out.println("this is for window closing");
System.exit(0);
}
}
class frame extends Frame implements ActionListener,ItemListener
{
Checkbox c1,c2,c3,c4,c5,c6;
boolean d1,d2,d3,d4,d5,d6;
Font f1;
int x;
frame()
{
setLayout(null);
//u edit this code instead of manually repeating the same code u use for loop which is easy and reduce the length of the code and increase the readability of the program
f1=new Font("Sanserif",Font.ITALIC,20);
Label l1=new Label("enter the name",Label.LEFT);
l1.setBounds(400,400,100,10);
Label l2=new Label("father name",Label.LEFT);
l2.setBounds(400,420,100,10);
Label l3=new Label("house no",Label.LEFT);
l3.setBounds(400,440,100,10);
Label l4=new Label("street",Label.LEFT);
l4.setBounds(400,460,100,10);
Label l5=new Label("town",Label.LEFT);
l5.setBounds(400,480,100,10);
Label l6=new Label("district",Label.LEFT);
l6.setBounds(400,500,100,10);
Label l7=new Label("state",Label.LEFT);
l7.setBounds(400,520,100,10);
Label l8=new Label("E-mail",Label.LEFT);
l8.setBounds(400,540,100,10);
Label l9=new Label("mobileno",Label.LEFT);
l9.setBounds(400,560,100,10);
Label l10=new Label("this is designed by kalyan",Label.LEFT);
l10.setBounds(400,580,100,10);
add(l1);
add(l2);
add(l3);
add(l4);
add(l5);
add(l6);
add(l7);
add(l8);
add(l9);
add(l10);
Button b1=new Button("red");
b1.addActionListener(this);
b1.setBounds(700,500,50,16);
Button b2=new Button("green");
b2.setBounds(700,520,50,16);
b2.addActionListener(this);
Button b3=new Button("yellow");
b3.setBounds(700,540,50,16);
b3.addActionListener(this);
Button b4=new Button("cyan");
b4.setBounds(700,560,50,16);
b4.addActionListener(this);
Button b5=new Button("magenta");
b5.setBounds(700,480,50,16);
b5.addActionListener(this);
c1=new Checkbox("title1");
c1.addItemListener(this);
c1.setBounds(100,400,100,20);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(c1);
}
public void itemStateChanged(ItemEvent ie)
{
d1=c1.getState();
repaint();
}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
if(s.equals("red"))
x=1;
else
if(s.equals("green"))
x=2;
else
if(s.equals("yellow"))
x=3;
else
if(s.equals("cyan"))
x=4;
else
if(s.equals("magenta"))
x=5;
repaint();
}
public void paint(Graphics g)
{
Font f=new Font("Helvetica",Font.BOLD,14);
g.setFont(f);
g.drawString("@ramu dayinaboyina ",600,400);
g.setColor(Color.red);
g.drawString("1)D.C.M.E(Diploma in ComputerMaintainceEngg)",50,300);
g.drawString("2)D.C.E(Dipoma in Civil Engg)",50,320);
g.drawString("3)D.E.E.E(Diploma in Electrical &Electronical Engg)",50,340);
g.drawString("4)D.E.C.E(Diploma in Electronics &Electrical Engg)",50,360);
g.drawString("5)D.M.E(Diploma in Mechanical Engg)",50,380);
g.setColor(Color.green);
f=new Font("Helvetica",Font.BOLD,24);
g.setFont(f);
g.drawString("POLYTECHNIC CHIRALA" ,50,100);
g.setColor(Color.blue);
g.drawString("The Courses Offered for the year 2006-2007 are",50,200);
g.setColor(Color.cyan);
g.drawString("This is the HomePabe ",220,250);
g.drawString("this college is located in 10 acars and large buldings ,play grounds",50,260);
if(d1==true)
{
g.setColor(Color.cyan);
g.drawString("you clicked title1",40,20);
}
if(x==1)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font",400,400);
setBackground(Color.red);
}
if(x==1)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with red color",200,400);
setBackground(Color.red);
}
if(x==2)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with green color",200,400);
setBackground(Color.green);
}
if(x==3)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with yellow color",200,400);
setBackground(Color.yellow);
}
if(x==4)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with cyan color",200,400);
setBackground(Color.cyan);
}
if(x==5)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with magenta color",200,400);
setBackground(Color.magenta);
}
}
public static void main(String r[])
{
frame f=new frame();
f.setVisible(true);
f.setSize(300,250);
f.setTitle("this is an example for the java frames");
System.out.println("to exit from the program press ctrl+c");
f.setBounds(0,0,1240,860);
f.setBackground(Color.yellow);
boolean b=f.isResizable();
System.out.println("the return value is true or false for resizeing"+b);
b=f.isResizable();
System.out.println("the return value is true or false for resizeing"+b);
int c=f.getState();
System.out.println("the value of the state of the frame is "+c);
f.setState(4);
c=f.getState();
System.out.println("after setting of the the value of the state of the frame is "+c);
System.out.println("the value fo the under corated is "+b);
System.out.println("ok successfully you created the frame concept in this session");
c=f.getCursorType();
System.out.println("the style fo the cursor is "+c);
f.addWindowListener(new wh());
}}
import java.awt.event.*;
class wh extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.out.println("this is for window closing");
System.exit(0);
}
}
class frame extends Frame implements ActionListener,ItemListener
{
Checkbox c1,c2,c3,c4,c5,c6;
boolean d1,d2,d3,d4,d5,d6;
Font f1;
int x;
frame()
{
setLayout(null);
//u edit this code instead of manually repeating the same code u use for loop which is easy and reduce the length of the code and increase the readability of the program
f1=new Font("Sanserif",Font.ITALIC,20);
Label l1=new Label("enter the name",Label.LEFT);
l1.setBounds(400,400,100,10);
Label l2=new Label("father name",Label.LEFT);
l2.setBounds(400,420,100,10);
Label l3=new Label("house no",Label.LEFT);
l3.setBounds(400,440,100,10);
Label l4=new Label("street",Label.LEFT);
l4.setBounds(400,460,100,10);
Label l5=new Label("town",Label.LEFT);
l5.setBounds(400,480,100,10);
Label l6=new Label("district",Label.LEFT);
l6.setBounds(400,500,100,10);
Label l7=new Label("state",Label.LEFT);
l7.setBounds(400,520,100,10);
Label l8=new Label("E-mail",Label.LEFT);
l8.setBounds(400,540,100,10);
Label l9=new Label("mobileno",Label.LEFT);
l9.setBounds(400,560,100,10);
Label l10=new Label("this is designed by kalyan",Label.LEFT);
l10.setBounds(400,580,100,10);
add(l1);
add(l2);
add(l3);
add(l4);
add(l5);
add(l6);
add(l7);
add(l8);
add(l9);
add(l10);
Button b1=new Button("red");
b1.addActionListener(this);
b1.setBounds(700,500,50,16);
Button b2=new Button("green");
b2.setBounds(700,520,50,16);
b2.addActionListener(this);
Button b3=new Button("yellow");
b3.setBounds(700,540,50,16);
b3.addActionListener(this);
Button b4=new Button("cyan");
b4.setBounds(700,560,50,16);
b4.addActionListener(this);
Button b5=new Button("magenta");
b5.setBounds(700,480,50,16);
b5.addActionListener(this);
c1=new Checkbox("title1");
c1.addItemListener(this);
c1.setBounds(100,400,100,20);
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(c1);
}
public void itemStateChanged(ItemEvent ie)
{
d1=c1.getState();
repaint();
}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
if(s.equals("red"))
x=1;
else
if(s.equals("green"))
x=2;
else
if(s.equals("yellow"))
x=3;
else
if(s.equals("cyan"))
x=4;
else
if(s.equals("magenta"))
x=5;
repaint();
}
public void paint(Graphics g)
{
Font f=new Font("Helvetica",Font.BOLD,14);
g.setFont(f);
g.drawString("@ramu dayinaboyina ",600,400);
g.setColor(Color.red);
g.drawString("1)D.C.M.E(Diploma in ComputerMaintainceEngg)",50,300);
g.drawString("2)D.C.E(Dipoma in Civil Engg)",50,320);
g.drawString("3)D.E.E.E(Diploma in Electrical &Electronical Engg)",50,340);
g.drawString("4)D.E.C.E(Diploma in Electronics &Electrical Engg)",50,360);
g.drawString("5)D.M.E(Diploma in Mechanical Engg)",50,380);
g.setColor(Color.green);
f=new Font("Helvetica",Font.BOLD,24);
g.setFont(f);
g.drawString("POLYTECHNIC CHIRALA" ,50,100);
g.setColor(Color.blue);
g.drawString("The Courses Offered for the year 2006-2007 are",50,200);
g.setColor(Color.cyan);
g.drawString("This is the HomePabe ",220,250);
g.drawString("this college is located in 10 acars and large buldings ,play grounds",50,260);
if(d1==true)
{
g.setColor(Color.cyan);
g.drawString("you clicked title1",40,20);
}
if(x==1)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font",400,400);
setBackground(Color.red);
}
if(x==1)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with red color",200,400);
setBackground(Color.red);
}
if(x==2)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with green color",200,400);
setBackground(Color.green);
}
if(x==3)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with yellow color",200,400);
setBackground(Color.yellow);
}
if(x==4)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with cyan color",200,400);
setBackground(Color.cyan);
}
if(x==5)
{
g.setFont(f1);
g.drawString("you are implementing the sanserif font with magenta color",200,400);
setBackground(Color.magenta);
}
}
public static void main(String r[])
{
frame f=new frame();
f.setVisible(true);
f.setSize(300,250);
f.setTitle("this is an example for the java frames");
System.out.println("to exit from the program press ctrl+c");
f.setBounds(0,0,1240,860);
f.setBackground(Color.yellow);
boolean b=f.isResizable();
System.out.println("the return value is true or false for resizeing"+b);
b=f.isResizable();
System.out.println("the return value is true or false for resizeing"+b);
int c=f.getState();
System.out.println("the value of the state of the frame is "+c);
f.setState(4);
c=f.getState();
System.out.println("after setting of the the value of the state of the frame is "+c);
System.out.println("the value fo the under corated is "+b);
System.out.println("ok successfully you created the frame concept in this session");
c=f.getCursorType();
System.out.println("the style fo the cursor is "+c);
f.addWindowListener(new wh());
}}
కామెంట్లు లేవు:
కామెంట్ను పోస్ట్ చేయండి