package VentanasYEventos;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
public class TestInner {
private Frame f;
private TextField tf;
public TestInner()
{
f=new Frame("Ejemplo de clases internas");
tf=new TextField(30);
}
class MyMouseMotionListener extends MouseMotionAdapter
{
public void mouseDragged(MouseEvent e)
{
String s="Mouse Dragging : X= "+e.getX()+"Y = "+e.getY();
tf.setText(s);
}
}
public void launchFrame()
{
Label label=new Label("Click y drag del mouse");
f.add(label, BorderLayout.NORTH);
f.add(tf, BorderLayout.SOUTH);
f.addMouseMotionListener(new MyMouseMotionListener());
f.addMouseListener(new MouseClickHandler());
f.addWindowListener(new Manejador());
f.setSize(300,200);
f.setVisible(true);
}
public static void main(String[] args) {
TestInner t=new TestInner();
t.launchFrame();
}
}
No hay comentarios:
Publicar un comentario