?
Solved

How to shift image ?

Posted on 1997-04-07
1
Medium Priority
?
213 Views
Last Modified: 2011-08-18
I want to copy an area of image from left to right to make it looks like it "grow" from left to right. So I wrote the following codes :

int n = 300;
while( n > 0 )
{
      g.copyArea(n, 0, 3, 50, 3, 0);
      n = n-3;
}

And I already draw lines at 0,0 to 3,50. It should reduplicate that image once when I call the above loop. But it just can't work, it doesn't duplicate anything at all !

But if I change the logic of loop to:

int n = 0;
while( n > 300)
{
      g.copyArea(n, 0, 3, 50, 3, 0);
      n = n+3;
}

Then it can work, and show me a lines of image, duplicated from the left hand side.

Why such happened ? What's wrong of my code or logic ?

Please help me !! Thank you very much !! ( Urgent ! )
0
Comment
Question by:c.w.yuen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
majkl earned 300 total points
ID: 1219501
int n = 0;
             while( n > 300)
             {
             g.copyArea(n, 0, 3, 50, 3, 0);
             n = n+3;
             }

this loops never loops.
n = 0 and while n > 300
statement is everytime false :)


0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question