Pages

Subscribe:

Blogger templates

Sample Text

Total Pageviews

Followers

About Us

My Photo
MY Name is Vicky. I am student in Univercity.Programming and webdesigning but i don't like Maths.Someone should kill the teacher .Besides i like writing stories ,and sciencefiction scripts .Soon i will have my book and a movie !!Like so much cooking & travelling all over the world an learn about other cultures! An artistic kid and art is my breath !

Thursday, July 16, 2009

2 BUTTONS,WHEN PRESSED CHANGE BACKGROUND

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Buttons1 extends Applet implements ActionListener{
Button bt1, bt2;
String s;
public void init(){
bt1=new Button("Kitrino");
add(bt1);
bt1.addActionListener(this);
bt2=new Button("Kokkino");
add(bt2);
bt2.addActionListener(this);
}
public void paint (Graphics g){
if (s=="Kitrino")
setBackground(Color.yellow);
else if (s=="Kokkino")
setBackground(Color.red);
repaint();
}
public void actionPerfomed(ActionEvent e){
s=e.getActionCommand();
}
}

0 comments:

Post a Comment