Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:05:08+00:00 2026-06-04T07:05:08+00:00

I have to make a rotating rectangle on my applet, how is it done?

  • 0

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);
     }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:05:09+00:00Added an answer on June 4, 2026 at 7:05 am

    I am not going to write your applet for you, but I’ll give you some steps to get you started:

    In your init:

    • Set a timer, that calls the refresh method every time.
    • Set a global counter to 0

    In your refresh method:

    • Increase the counter by 1 (possibly mod 360 to keep it in the 0-359 range)
    • Call the repaint method

    In your paint method:

    • Turn the Canvas the number of degrees the counter is on (possibly
      using an AffineTransform object)
    • Paint your image/square/shape/anything

    Good luck 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I make an object rotate around its axis? i.e. having the moon
I have make one site using Zend Framework. Its working fine in development server
Using this sample : I have make my own Fragment that holds tabhost and
I have make a parallelogram with CSS3. With this code: #parallelogram { width: 150px;
I have make a soap-call with Savon. This works fine and give the following
I have make one cron job as below <?php echo HI; ?> When i
I have make this script: $(#comments .comment .links).hide(); $(#comments .comment).hover( function() { $(.links, this).stop(true).slideDown(300);
I have make a new dropdown navi in css . Chrome, firefox, safari is
I have make a messaging system in which user can send messages to each
I have to make a graphical user interface application using the language of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.