2个回答
展开全部
import java.applet.Applet;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class Sort extends Applet{
public void init(){
addMouseListener(new MouseAdapter1());
}
public void paint(Graphics g){
Font f= new Font("宋体",Font.PLAIN,20);
g.setFont(f);
g.setColor(Color.BLUE);
g.drawString("画矩形",100,100);
}
public class MouseAdapter1 extends MouseAdapter {
int x,y;
public void mousePressed (MouseEvent e)
{
x = e.getX();
y = e.getY();
}
public void mouseReleased (MouseEvent e)
{
Graphics g;
g=getGraphics();
g.drawRect(x,y,(e.getX()-x),(e.getY()-y));
}
}
}
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class Sort extends Applet{
public void init(){
addMouseListener(new MouseAdapter1());
}
public void paint(Graphics g){
Font f= new Font("宋体",Font.PLAIN,20);
g.setFont(f);
g.setColor(Color.BLUE);
g.drawString("画矩形",100,100);
}
public class MouseAdapter1 extends MouseAdapter {
int x,y;
public void mousePressed (MouseEvent e)
{
x = e.getX();
y = e.getY();
}
public void mouseReleased (MouseEvent e)
{
Graphics g;
g=getGraphics();
g.drawRect(x,y,(e.getX()-x),(e.getY()-y));
}
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询