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 6008269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:48:03+00:00 2026-05-23T01:48:03+00:00

I have a small panel where i am making a ball to move by

  • 0

I have a small panel where i am making a ball to move by just varying it’s x co-ordinate.
I want the ball move back when it encounters the end of frame.The width of my frame is 300
(by fr.setSize(300,300)).
Now I programmed the animation like :

// when x == 300
// stop the timer

But x=300 seems to be greater than it’s width which is 300 ! How is this possible.
**The ball moves out of the 300 x 300 frame and becomes invisible.
Why is this happening ?

These are the screen shots of what happens eventually.

Ball is moving...

Ball is no where..!!

Upon Enlarging,ball is there

First snapshot is that of the moving ball,second shows that ball has disappeared,third shows on enlarging that ball is there.

Why this happens.? How can i set the frame’s end point as the ball’s end point?

  • 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-05-23T01:48:03+00:00Added an answer on May 23, 2026 at 1:48 am

    You need to consider the viewable size of your component. It won’t necessarily be the same as the size you requested.

    You can use the getSize method to determine the actual size of your component, but you also need to call getInsets to find out if any space has been reserved for use by borders. This will give you the real, drawable area:

    public void paint(Graphics g) {
        Dimension size = getSize();
        Insets insets = getInsets();
        int available = size.width - insets.left - insets.right;
        // Draw stuff. Remember to offset by insets.left and insets.top!
        ...
    }
    

    Also remember that Graphics routines like fillOval draw down and to the right of the coodinate you specify, so you need to think about what the ball coordinate means. Is it the center of the ball, or the left or right side? You may need to subtract the width of the ball when calculating whether it has reached the side of the drawable area or not.

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

Sidebar

Related Questions

I have small problem with my .net 2.0 winforms application. I want to embed
I've just finished designing a small android app and have now come to a
I have to load a small icon on the botton of my software. just
I have small page which has label, DropDownList and a submit button. <div> <asp:label
Where I work, we have small teams of 2 - 5 people. As a
I have a small JS function that does Ajax for me and another like
I have a small utility that I use to download an MP3 file from
I have a small local network. Only one of the machines is available to
I have a small VB.NET application that I'm working on using the full version
I have a small diagnostic VB.Net application ( 2 forms, 20 subs & functions)

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.