• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

confused...

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
excuse me, can someone please enlighten me...
What is the difference between repaint() and calling paint(g)?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually you won't ever call paint(Graphics g) yourself directly. If you want paint() to run you will call repaint(). Now this is because paint is called from a seperate thread, not a thread that you create, and can run at the JVMs choosing. So the only way to force that paint will run is to call repaint() then serviceRepaints() right after each other.

Mark
 
Lawrence Buensalida
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, if you want to call the paint(Graphics g) you use the repaint(), right?

Another...I have a problem with this:



Some codes here



* This should display an image. 2 images of correcthalf.png and correctall.png in different x positions.
* The x value changes because of the variable TRctr.

However, when I run the midlet, it only displays 1 image. It only displays the last correctall.png image without the other images.

Why is this so?

Help me. Please?
[ July 26, 2005: Message edited by: Mark Spritzler ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First lets, put CODE tags around the code so that we can see the formatting. And lets put those curly braces on the lines above, line them up better, and change the variable names all so that it follows the Sun Java Coding Standards. Coding standards are very very important so that everyone can read the code.

Now we can read the code without being distracted.
[ July 26, 2005: Message edited by: Mark Spritzler ]
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, you will alson eed to change the variable names like GbLeft , GbTop. All variables should start with a lower case letter, then follow the camelback format, where each new word after the first word in a variable name is capitalized.

Where are those variables defined anyway, as well as perSpace, and image?

Well, I can't tell what you are trying to do by those calculations, but my wild guess is that the result of x is so large for the second image that it is off screen.

Mark
 
Lawrence Buensalida
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh, I'm sorry. Here are my variable declarations:

public int GbLeft; // this value is 108;
public int GbTop; // this value is 96;
public int perSpace; // this initial value for this is 1

public Boolean checking; // Relevant indicator for assignResult to be performed
public Image[] resultImage = new Image[4]; // array to hold an image
public int RIctr; // counter for Result Image
public int TRctr;



some codes here




Mark, What I have here is a revised version of my code. I changed displayResult to assignResult wherein I assigned every image there inside the array. I called the repaint() so that every image is displayed.

The images were displayed, however, we have a new problem. After displaying the images inside the resultimage array, I received this error:



I think I have a problem with my repainting, don't you think so?


P.S.

Thanks for editing my displayed code (again). I hope I got it this time.
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your issue is in the paint method

NewGame.paint(+80)

Of course that +80 deosn't help much as it is a line number, but not the line number that you would see in your editor.

One of the Objects is not pointing to an instance and is calling a method.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You also need to change your variable naming to follow the Sun Java Coding Standards. Variables should never ever start with a capital letter.

Personally, I think the variable naming is the biggest bug that you have in your code.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have your checking variable set to the Boolean wrapper class, yet trying to assign it to a boolean primitive value.

Unless you need to convert boolean values from the primitive to Strings and/or putting these into a Collections class, I would not use the Boolean wrapper class. keep to using the boolean primitive.

Mark
[ July 27, 2005: Message edited by: Mark Spritzler ]
 
Lawrence Buensalida
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for suggesting the standard, I'll do that.

One more thing, what is the difference between what I did with my checking variable (being a Boolean something) and the one that you want me to practice?

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic