编写一个APPLET,要求在界面上绘制一矩形,并且绘制矩形的内切椭圆和矩形的两条对角线
2个回答
展开全部
按照你的要求编写的Java Applet程序如下:
import java.applet.Applet;
import java.awt.Graphics;
public class GGG extends Applet{
public void init(){
setSize(300,300);
}
public void paint(Graphics g){
super.paint(g);
g.drawRect(50, 50, 200, 100);
g.drawOval(50, 50, 200, 100);
g.drawLine(50, 50, 250, 150);
g.drawLine(50, 150,250, 50);
}
}
展开全部
import java.applet.Applet;
import java.awt.Graphics;
public class Ticket extends Applet
{
/**
*
*/
public Ticket()
{
super();
}
private static final long serialVersionUID = 2787645621825874902L;
public void init()
{
}
public void paint(Graphics g)
{
int l = 100, t = 100, r = 400, b = 300;
g.drawRect(l, t, r, b);
g.drawOval(l, t, r, b);
g.drawLine(l, t, r + l, b + t);
g.drawLine(r + l, t, l, b + t);
}
}
import java.awt.Graphics;
public class Ticket extends Applet
{
/**
*
*/
public Ticket()
{
super();
}
private static final long serialVersionUID = 2787645621825874902L;
public void init()
{
}
public void paint(Graphics g)
{
int l = 100, t = 100, r = 400, b = 300;
g.drawRect(l, t, r, b);
g.drawOval(l, t, r, b);
g.drawLine(l, t, r + l, b + t);
g.drawLine(r + l, t, l, b + t);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询