Solved

How to shift image ?

Posted on 1997-04-07
1
209 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
1 Comment
 
LVL 2

Accepted Solution

by:
majkl earned 100 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java JRE greater than 1.6 5 62
how to add new optional parameter to JSP 1 40
javap not working 8 44
hibernate example for saving data 19 37
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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

776 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