Solved

How to shift image ?

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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 …

691 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