import java.awt.event.*
class dlg extends Frame implements WindowListener
{
private static final long serialVersionUID = 1L
dlg(String s,int l,int t,int w,int h)
{
setTitle(s)
setLayout(new FlowLayout(FlowLayout.LEFT,50,50))
Toolkit tool=getToolkit()
Dimension dim=tool.getScreenSize()
setBounds(dim.width/2-200,dim.height/2-150,400,300)
setBounds(l,t,w,h)
addWindowListener(this)
}
@Override
public void windowActivated(WindowEvent arg0) {
// TODO Auto-generated method stub
} @Override
public void windowClosed(WindowEvent arg0) {
// TODO Auto-generated method stub
} @Override
public void windowClosing(WindowEvent arg0) {
// TODO Auto-generated method stub
System.exit(0)
} @Override
public void windowDeactivated(WindowEvent arg0) {
// TODO Auto-generated method stub
} @Override
public void windowDeiconified(WindowEvent arg0) {
// TODO Auto-generated method stub
} @Override
public void windowIconified(WindowEvent arg0) {
// TODO Auto-generated method stub
} @Override
public void windowOpened(WindowEvent arg0) {
// TODO Auto-generated method stub
}
}class mybt extends Button implements MouseListener
{
mybt(String caption,int l,int t,int w,int h)
{
setLabel(caption)
setBounds(l,t,w,h)
addMouseListener(this)
}
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
} @Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
int bx=(int)((Math.random()+0.01)*200)
int by=(int)((Math.random()+0.01)*200)
setLocation(bx,by)
} @Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
} @Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
} @Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}
public class ebt{
public static void main(String s[])
{
dlg d=new dlg("EscapeButton(Make By GG):",300,200,400,300)
mybt bt =new mybt("有本事就来点击我",10,10,40,20)
bt.setBounds(20, 20, 40, 20)
d.add(bt)
d.setVisible(true)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)