| Reply | « Previous Thread | Next Thread » |
|
I just moved from "Forms" to Canvas and I wonder how I add an Image to a Canvas so it will be displayed on the phone....
|
|
Code:
public void paint(Graphics g) {
g.drawImage(myBackgroundImage,0,0,Graphics.TOP|Graphics.LEFT);
// the rest of the painting code
}
|
|
Hi,
Use paint(Graphics g) Method. and as per your req use repaint method. Regards Chandu |
| chandu_bgm |
| View Public Profile |
| Find all posts by chandu_bgm |
|
What is the relation between paint and repaint
|
|
zivgr
paint() is called by the phone, when it thinks that image should update. repaint() is called by you and makes phone think so :) |
|
Thanks for your reply...
So the phone only call paint() if I call repaint? What are the situations in which paint() is called? |
|
zivgr
You should read documentation. It's not that simple question. Generally you are right, phone calls paint(), when you call repaint(), but there are some details, like phone actually cals paint(), when it has time, you can force it by calling serviceRepaints, etc. |
|
Thanks.
How can I have in Canvas the same text wrapping functionality that there is in Forms? Does someone have a piece of code that does thais task? |
|
Hi
Look there are many Situations wher do you want use the paint (),repaint() and/or serviceRepaints().But all depends on for what perpose you are using it... I mean If you are using that for games the way of doing this are different and for general display of graph its different.. So think of the situation and use the methodes wisely....:) I hope this will help Regards Chandu |
| chandu_bgm |
| View Public Profile |
| Find all posts by chandu_bgm |
|
zivgr
How can I have in Canvas the same text wrapping functionality that there is in Forms? Implemet it yourself. Actually it's not that complex. Does someone have a piece of code that does thais task? Yes I've seen an example somewhere in common place. I think it was on Sun's Wireless Developer or here, on Forum Nokia. Check their examples. However, there was nothing fantastic in those examples - just simple calculation of position, where to wrap. |
|
|
|
Thanks!!!
Does someone know whether it is possible to scroll a Canvas as in a Form??? |
|
zivgr
Does someone know whether it is possible to scroll a Canvas as in a Form??? Canvas is called canvas, because it's just a pack of pixels to set values. You can draw there anything you want, but it's absolutely up to you, whether to implement any extra non-drawing (or keypress handling) functionality. Of course, for such popular needs as game scrolling there are some usual ways to do it, but anyway you should implement it. P.S. I haven't done anything for MIDP 2.0. There are a lot of enhancements for game developers. Maybe there is some standard solution for scrolling also. |
|
Does someone know whether it is possible to scroll a Canvas as in a Form???
Yes Its possible to scroll .....It can be done by manipulating the Cords..(X-axis,Y-axis). I hope this may help. Regards Chandu |
| chandu_bgm |
| View Public Profile |
| Find all posts by chandu_bgm |
|
Thanks chandu.
Could you please give some more details or a reference, as I'm quite new to the subject. |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|