Sie sind auf Seite 1von 1

import java.lang.*; import java.io.*; import java.awt.*; import java.awt.event.

*; class WindowHandler extends WindowAdapter { public void windowClosing(WindowEvent we) { System.exit(0); } } class Demo1 extends Frame implements MouseListener { public Demo1(String str) { super(str); setVisible(true); setSize(1000,700); Toolkit tk=Toolkit.getDefaultToolkit(); Dimension ss=tk.getScreenSize(); Dimension fs=getSize(); int x=(ss.width-fs.width)/2; int y=(ss.height-fs.height)/2; setLocation(x,y); addWindowListener(new WindowHandler()); Font ft=new Font("Arial Black",Font.BOLD,25); setFont(ft); setForeground(Color.RED); addMouseListener(this); } public void mouseEntered(MouseEvent me) { setBackground(Color.red); } public void mouseExited(MouseEvent me) { setBackground(Color.green); } public void mousePressed(MouseEvent me) { setBackground(Color.blue); } public void mouseReleased(MouseEvent me) { setBackground(Color.yellow); } public void mouseClicked(MouseEvent me) { setBackground(Color.orange); } public static void main(String args[]) { Frame f=new Demo1("Sample Window"); } }

Das könnte Ihnen auch gefallen