[英]Draw a rotating rectangle on applet
I have to make a rotating rectangle on my applet, how is it done? 我必须在我的applet上制作一个旋转矩形,它是如何完成的? The rectangle should rotate around one of its conner on the plane.
矩形应围绕平面上的其中一个旋转。 This is what I have so far:
这是我到目前为止:
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JApplet;
public class MainApplet extends JApplet {
Font bigFont;
Color redColor;
Color weirdColor;
Color bgColor;
@Override
public void init()
{
bigFont = new Font("Arial",Font.BOLD,16);
redColor = Color.red;
weirdColor = new Color(60,60,122);
setBackground(bgColor);
}
@Override
public void stop() { }
@Override
public void paint(Graphics g)
{
g.setFont(bigFont);
g.drawString("Shapes and Colors",80,20);
g.setColor(redColor);
g.drawRect(100,100,100,100);
g.fillRect(100,100,100,100);
}
}
I am not going to write your applet for you, but I'll give you some steps to get you started: 我不会为你编写你的applet,但我会给你一些步骤来帮助你入门:
In your init: 在你的init:
In your refresh method: 在您的刷新方法中:
In your paint method: 在你的绘画方法:
Good luck :) 祝好运 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.