import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Klavye extends Applet implements MouseListener, ActionListener,KeyListener {
String mesaj="Klavyenizden bir tusa basin lütfen";
Point nokta;
Button sil;
TextArea alan;
Label kareSayisi;
int sayi=0;
int x;
int y;
char karakter;
public void init() {
setBackground(Color.pink);
sil= new Button("Clear");
alan=new TextArea(5,20);
kareSayisi= new Label("Kare Sayisi");
addMouseListener(this);
addKeyListener(this);
sil.addActionListener(this);
add(kareSayisi);
add(alan);
add(sil);
}
public void paint(Graphics g) {
System.out.println("gozde");
Font f = new Font("Arial",Font.BOLD , 14);
g.setFont(f);
}
public void actionPerformed(ActionEvent e)
{
String tik=e.getActionCommand();
if(tik.equals("Clear"))
{
Graphics g = getGraphics();
g.setColor(Color.pink);
g.fillRect(0,0,700,700);
sayi=0;
alan.setText("ekran silindi");
}
}
public void keyPressed(KeyEvent event){
System.out.println("jh");
}
public void keyReleased(KeyEvent event){
}
public void keyTyped(KeyEvent event){
}
public void mousePressed(MouseEvent e)
{
Graphics g = getGraphics();
nokta=e.getPoint();
g.setColor(Color.blue);
x=(nokta.x-10);
y=(nokta.y-10);
g.drawRect(x,y,20,20);
sayi++;
alan.setText(" "+sayi);
}
public void mouseMoved(MouseEvent e)
{
}
public void mouseDragged(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
}
arakadaslar bu kod neden kalvye hareketlerine duyarlı degil?
|