Solved

How to shift image ?

Posted on 1997-04-07
1
203 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now