aspose file tools*
The moose likes Java Micro Edition and the fly likes confused... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "confused..." Watch "confused..." New topic
Author

confused...

Lawrence Buensalida
Ranch Hand

Joined: May 18, 2005
Posts: 38
excuse me, can someone please enlighten me...
What is the difference between repaint() and calling paint(g)?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Lawrence Buensalida
Ranch Hand

Joined: May 18, 2005
Posts: 38
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
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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

Joined: May 18, 2005
Posts: 38
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
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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

Joined: May 18, 2005
Posts: 38
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?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confused...