Reputation: 1954
I have to make a rotating rectangle on my applet, how is it done? 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);
}
}
Upvotes: 0
Views: 1769
Reputation: 11931
I am not going to write your applet for you, but I'll give you some steps to get you started:
In your init:
In your refresh method:
In your paint method:
Good luck :)
Upvotes: 2