pushRegion, pushContext and popContext - how does it work?

I try to wear a J2ME application to the Blackberry API. I tried to use pushRegion to replace setClip to J2ME but it seems that these two methods behave different. I have an image with 7 buttons, one above the other, each with a height fixed 13 pixels and the only other thing is their collor, each of them is lighter than the previous. I want to put the clip to draw a certain button, but the way that I use pushRegion is not correct and only a small piece is sometimes drawn, sometimes nothing is drawn. If I do the pushRegion for the whole of the screen the image is drawn. Here is my code:

graphics.pushRegion(new XYRect(0, positionY, screenWidth, buttonHeight));

graphics.drawBitmap((screenWidth - buttonImage.getWidth()) / 2,          positionY - buttonFrame[i] * buttonHeight,
buttonImage.getWidth(), buttonImage.getHeight(), buttonImage, 0, 0);

graphics.popContext();

Use pushContext instead of pushRegion

And another problem: after several drawings (I do drawing in a loop for) I get the error "out of memory" on the emulator, I guess it is because of the pushRegion and the popContext, because I do not create other objects.

I had to use pushContext instead of pushRegion and everything is ok. But maybe someone can tell me the difference between these two methods.

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for

  • Lost the menu bar

    Recently, I lost the items bar menu at the top of the screen.

  • envy K220 nr: beats audio for windows 10

    After you have installed windows 10, beats audion is not entirely worked. Beats audio is present, but I can't enjoy the sound as it was before installin windows 10. It was working fine when newly purchased and windows 8 built in already. I installed

  • damaged library file

    My SSD worked more properly and the library files got scrambled. I tried to delete the library files and let iTunes new build but the songs are no longer with the good albums and when they are in the right albums, many of them are listed twice... Doe

  • Acer gateway ne570 won't boot upward and I tried the bios and it always detects the hard drive

    I have an acer gateway ne570 and it does not start and I tried the bios and it always detects the hard drive but first boot priority is boot windows which is the only thing on the menu Manager startup options when you press on enter where the box "no

  • Playback devices does not recognize an output HDMI for sound!

    I have my HDMI connected with video but my output of sounds/audio/playbackdevices does not recognize that I have a connected TV, how do audio? theres no monitor to set as audio device by default!