package AWT;
import java.awt.Color;
import java.awt.Frame;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class ColorTest {
Frame f=null;
public static void main(String[] args) {
new ColorTest();
}
//constructor
public ColorTest()
{
f=new Frame();
f.setTitle("Color TESt");
f.setSize(300,150);
f.setBackground(Color.BLACK);
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
f.setVisible(true);
f.addMouseMotionListener(new MouseMotionAdapter()
{
public void mouseMoved(MouseEvent ev)
{
int r=f.getBackground().getRed();
if(r<255)
f.setBackground(new Color(r+1,0,0));
else
f.setBackground(Color.BLACK);
}
});
}
}
No hay comentarios:
Publicar un comentario