🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: cn.bbs.comp.lang.java
Article #18792

���һ����Ŀ(��������)

#18792
From: bluestar
Date: Wed, 28 Jan 2004 07:44
52 lines
2201 bytes
��Ŀ:���һ��Frame���ڣ������и���ť�����ǿ���ʹ���������ק��ť���Ѱ�ť�ŵ�
��ŵ�λ���ϡ�

��д�ij���
import java.awt.*;
import java.awt.event.*;

public class test extends MouseMotionAdapter
{
    Button b1;
    public static void main(String argv[])
    {
        new test();
    }
    public test()
    {
        Frame f = new Frame("test");
        f.setLayout(null);
        b1 = new Button("Button1");
        b1.setSize(50,50);
        b1.setLocation(20,20);
        f.add(b1);
        f.addMouseMotionListener(this);
        f.addWindowListener(new WindowEventHandler());
        f.setSize(300,300);
        f.setVisible(true);
    }
    
    public void mouseDragged(MouseEvent e)
    {
        if(b1.hasFocus())
        {
            int x = e.getX();
            int y = e.getY();
            b1.setLocation(x,y);
        }
    }
}

class WindowEventHandler extends WindowAdapter
{
    public void windowClosing(WindowEvent e)
    {
        System.exit(0);
    }
}

��������һ����ֻҪ�ڴ�������ק��궼�ܸı䰴ť��λ�á���Ŀ��Ҫ��Ӧ�ò�������
�İɡ�
����Ҫ��ô�ģ��������ҵ�������Ͳ��ԣ�
--
�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 220.113.170.233]
Technical Details
Message-ID: <4AQhJW$9qT@bbs.sjtu.edu.cn>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!c03.atl99!sjc70.webusenet.com!news.usenetserver.com!maily.cic.tsinghua.edu.cn!news.ccie.net.cn!SJTU

Show Full Headers
Complete Article Headers
X-Google-Language: Chinese,GB
X-Google-Thread: f6cb0,982699d81c5cb48a,start
X-Google-Attributes: gidf6cb0,public
X-Google-ArrivalTime: 2004-01-27 23:44:01 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!c03.atl99!sjc70.webusenet.com!news.usenetserver.com!maily.cic.tsinghua.edu.cn!news.ccie.net.cn!SJTU
From: xingchen.bbs@bbs.sjtu.edu.cn (bluestar)
Newsgroups: cn.bbs.comp.lang.java
Subject: ���һ����Ŀ(��������)
Date: 28 Jan 2004 07:44:25 GMT
Organization: ��ˮ˼Դ
Message-ID: <4AQhJW$9qT@bbs.sjtu.edu.cn>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: 8bit
X-Filename: Java/M.1075275440.A