You Are Here:

Community: Developer Discussion Boards

#1 Old drawString() is painting in BGImage - 2006-05-12, 15:19

Join Date: Nov 2005
Posts: 33
yafy
Offline
Registered User
hi folks,

my sonyericcson emulator's width:176 and height:220.
Im having one image with same height but double the width.

so,
g.drawImage(transparentImage,0,0,g.TOP|g.LEFT);

will display only the first half of the img.

when i press any key , i want to show the second hidden part of the same image so that it creates an illusion of moving.

when i used,
g.translate(-175,0);

its suddenly moving to second part but not creates any illusion of movement.

before painting transparentImage i ve already painted BGImage.

now if i use

g.translate(-175,0);
g.drawString("painting",8,96,g.TOP|g.LEFT);

the "painting " is painted in the BGImage and not on top of transparentImage.

Please suggest....

1. how to move the img gradually
2. how to drawstring on top of that moved img


Thanks in advance

yafy
Reply With Quote

#2 Old Re: drawString() is painting in BGImage - 2006-05-13, 08:45

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi,
instead of hardcoding the values for drawing the image just use variables that increases or decreases their values as the key is pressed.

thanks
Soku
Reply With Quote

#3 Old Re: drawString() is painting in BGImage - 2006-05-13, 09:26

Join Date: Nov 2005
Posts: 33
yafy
Offline
Registered User
thanks for reply...

i actually used the following code below,

for(int i=0;i<-175;i--){
g.translate(i,0);
try{
t.sleep(500);
}catch(Exception e){}
g.drawImage(interfaceImage,i,0,g.TOP|g.LEFT);

}

but its not working.Am i correct or how can i modify my code...
plz suggest.

yafy
Reply With Quote

#4 Old Re: drawString() is painting in BGImage - 2006-05-13, 11:58

Join Date: Mar 2006
Posts: 518
wang_shui
Offline
Super Contributor
Hi Yafy,

I think here is a problem in ur code.
where have u written the code.
does it execute the painting part.ie: does it call the repaint() & serviceRepaints() in the for loop itself ?
For every g.translate(i,0); u have to call repaint or servicerepaints()


If possible Can u please post the whole sample code


Wang
Reply With Quote

#5 Old Re: drawString() is painting in BGImage - 2006-05-15, 07:37

Join Date: Nov 2005
Posts: 33
yafy
Offline
Registered User
hi

Quote: "For every g.translate(i,0); u have to call repaint or servicerepaints()"
thats also not working.

Below is my paint :


public void paint(Graphics g)
{

System.out.println("enter into paint.....");

int w = g.getClipWidth();
int h = g.getClipHeight();

// wordWrap = new WordWrap(Font.getFont( Font.FACE_PROPORTIONAL,
// Font.STYLE_BOLD | Font.STYLE_PLAIN, Font.SIZE_SMALL ),QStr,w);

g.setFont( Font.getFont( Font.FACE_PROPORTIONAL,
Font.STYLE_BOLD | Font.STYLE_PLAIN, Font.SIZE_SMALL ) );


g.setGrayScale(255);

g.drawImage(BackgroundImage,0,0,g.TOP|g.LEFT);

g.drawImage(questionBarImage,0,0,g.TOP|g.LEFT);
g.setClip(0, 0, interfaceImage.getWidth(), interfaceImage.getHeight());

if(translateFlag == 1 ){

for(int i=0;i<-175;i--){
g.translate(i,0);
repaint();
g.drawImage(interfaceImage,i,0,g.TOP|g.LEFT);
try{
t.sleep(500);
}catch(Exception e){}

}

g.drawImage(okButtonImage,175,210,g.TOP|g.LEFT);
g.drawImage(passButtonImage,315,210,g.TOP|g.LEFT);

g.drawString(A1Str,215,86,g.TOP|g.LEFT);
g.drawString(A2Str,215,120,g.TOP|g.LEFT);
g.drawString(A3Str,215,154,g.TOP|g.LEFT);
g.drawString(A4Str,215,188,g.TOP|g.LEFT);
translateFlag = 0;
}else {}
if(playFlag == 1){
playFlag = 0;
switch(spinMidlet.randomCategory)
{

case 1:
translateFlag = 1;

g.drawImage(interfaceImage,0,0,g.TOP|g.LEFT);//first part of img is painted here correcty
g.drawImage(generalImage,75,5,g.TOP|g.LEFT);
//after painting generalimg i want to move the translateimg.

repaint();break;
case 2:

..........

}
}}
else{
g.drawImage(interfaceImage,0,0,g.TOP|g.LEFT);


}
g.drawImage(playButtonImage,10,210,g.TOP|g.LEFT);

}//end paint


ro be clear ,when i press play button (playFlag=1) generalimg is painted on interfaceimg and set translateflag =1 .after this only i want to translate(move) interfaceimg .

thanks
yafy
Reply With Quote

#6 Old Re: drawString() is painting in BGImage - 2006-05-16, 06:40

Join Date: Feb 2006
Posts: 689
soku123
Offline
Super Contributor
Hi Yafy,
Please use the paint method only for painting.Please avoid the logic and other non-painting methods from the paint method.

Thanks
Soku
Reply With Quote

#7 Old Re: drawString() is painting in BGImage - 2006-05-16, 19:09

Join Date: Mar 2006
Posts: 518
wang_shui
Offline
Super Contributor
Hi yafy.

http://www.microjava.com/developer/f...ontent_id=1835


here is a sample wich helps u to scroll an image.

Regards,
Wang
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrap text using drawString ? artemg Mobile Java General 6 2009-06-25 11:25
Is pixel by pixel painting possible in standard MIDP? MobileVisuals Mobile Java Media (Graphics & Sounds) 0 2006-01-02 20:37
More offscreen DrawString problems !!! (Series 60 J2ME SDK) cbazza@poliplus.com Mobile Java Media (Graphics & Sounds) 0 2003-06-13 22:00
Display text on Canvas other than drawString sengaste Mobile Java General 1 2003-04-15 12:00
bgcolor is not painting the entire screen harikrishnag Browsing and Mark-ups 1 2002-10-21 22:44

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d127641X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZgamesQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ