ButtonField personalized with images

Hi all

I am trying to create a custom ButtonField, I'm unable to remove the background gray color. Could someone tell me what's wrong with this code?

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.ButtonField;

public class BigButtonField extends ButtonField{

    private int backgroundColour = Color.BLACK;
    private Bitmap button;
    private Bitmap on = Bitmap.getBitmapResource("onbutton.png");
    private Bitmap off = Bitmap.getBitmapResource("offbutton.png");
    private int fieldWidth = Graphics.getScreenWidth();
    private int fieldHeight = 31;
    private int buffer = (Graphics.getScreenWidth() - 105) / 2;
    private String text;
    private Font fieldFont;

    public BigButtonField(String _text) {
        super(Field.FOCUSABLE);
        this.text = _text;
        button = off;
        fieldFont = FieldFont();
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    protected boolean navigationClick(int status, int time) {
        fieldChangeNotify(1);
        return true;
    }

    protected void onFocus(int direction){
        button = on;
        invalidate();
    }

    protected void onUnfocus(){
        button = off;
        invalidate();
    }

    public int getPreferredWidth() {
        return fieldWidth;
    }

    public int getPreferredHeight() {
        return fieldHeight;
    }

    protected void layout(int arg0, int arg1) {
        setExtent(getPreferredWidth(), getPreferredHeight());
    }

    public static Font FieldFont() {
        try {
            FontFamily theFam = FontFamily.forName("SYSTEM");
            return theFam.getFont(net.rim.device.api.ui.Font.BOLD, 14);
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        return null;
    }

    protected void drawFocus(Graphics graphics, boolean on){
        //
    }

    protected void fieldChangeNotify(int context){
        try {
            this.getChangeListener().fieldChanged(this, context);
        } catch (Exception exception) {
        }
    }

    protected void paint(Graphics graphics) {
        graphics.drawRect(0, 0, fieldWidth, fieldHeight);
        graphics.fillRect(10, 0, fieldWidth-200, fieldHeight);
        graphics.drawBitmap(0, 0, fieldWidth, fieldHeight, button, 0, 0);
        graphics.setColor(Color.BLACK);
        graphics.setFont(fieldFont);
        graphics.drawText(text, ((fieldWidth - fieldFont.getAdvance(text))/ 2) - 70, (fieldHeight - fieldFont.getHeight()) / 2);
    }
}

Please provide your suggestion. If you have any other sample for buttonField customized by using bitmap then please share here.

Buzz.

Hi all

I found the solution myself.

1. I spread "Field" in my code, which removed the gray area of the background.

2. I added a FieldChanglistner to the customed button whenever I use it.

Yet once again thanks to you.

Buzz.

Tags: BlackBerry Developers

Similar Questions

  • I need a box multi select drop-down list or list of selection with image or icon faclitliy

    Hello

    I tried to find a plugin or a jquery plugin that allows to perform the task of

    have a list of selection with images and there should be a facility such as multi select.

    How this can be accomplished. One have they implemented it in any of their application

    Any information will be greatly appreciated.

    Thank you

    pauljohny100 wrote:

    Hello

    I tried to find a plugin or a jquery plugin that allows to perform the task of

    have a list of selection with images and there should be a facility such as multi select.

    How this can be accomplished. One have they implemented it in any of their application

    Any information will be greatly appreciated.

    When ask questions user interface-related still State (at least) the full version of APEX, the theme and the version of browser compatibility / required.

    See the plugin jQuery Select2 , for which there is a plug in APEX .

    Pre-plugin when we have implemented requirements like this using a model report, CSS and personal...

  • Can I put a Word document with images in InDesign CC?

    Dear community - can I put a Word document with images in InDesign CC?

    Having been spoiled by always my own composition and page layout and currently

    have a person of InDesign layout to try my book, I returned to Sandee Cohen

    InDesign CC Visual Quickstart Guide hoping that I can learn what I need to know.

    I ask myself this question before really getting into InDesign CC book because my doc Word of the book

    I carefully designed with 140 photos and other images have been incorporated.

    Naturally, I hope that I can place in InDesign that way and not text first, followed by Visual effects.

    If I can add something that may or may not serious in the context of my question,.

    I just want to say that I published my spirit that moves us poetry and fiction press

    from 1975 to 2000 beginning to photograph the sending to the printer a

    plateau composer with 8K of memory and later on using QuarkXPress 4 (it's now up to 100)

    that I tried with my paper I inadvertently came to assume in 80 years, but found it impossible.

    InDesign was recommended to me by several people and I'm happy to have.

    Thank you

    Morty Sklar

    Jackson Heights, Queens, NYC

    Word preserves the entire image in the DOCX format.

    I wrote about it here: http://indesignsecrets.com/get-the-full-picture-with-docx.php

  • Online banking site now displays the page of connection in text alone; on the other computer it always shows the page with images and clickable - is - it a solution?

    Previously when I logged my INGdirect Bank online account, the window connection come showing images and clickable hotspots. Window connection changed recently, to a text only version. On two different computers using Firefox, the connection returns to the previous version, with images and clickable hotspots. I do not know to have done anything to change my settings in Firefox or on the website of the Bank. Because it seems to be located on this computer, I tried to download the latest version of Firefox, but didn't get any change, connection always comes back to the text-only format.

    Try to clear your browser's cache.

    Tools > clear recent history... - details and of course Cache hit only is selected, and then select all and click the clear now button.

  • HP ENVY 7640: Jobs of text with images - printer cancels

    When I print a text with images document the printer stop printing and cancels the print job when it starts to print any image.

    Help

    Hey @sudiegal!

    Thanks for posting on the HP Forums!

    I would be happy to provide you with some suggestions that may fix the problem.  I see that the printer cancels jobs when you add a photo to you text document.  The first thing I suggest is to remove the printer by resetting the printing system.  After removing the printer add printer and then try printing the document again.

    To reset the printing system:

    1. click on the Apple in the top left of the computer icon

    2. click on System Preferences

    3. click on printers and Scanners

    4 press and hold 'Ctrl' on the keyboard and click with the mouse in the space below the printer

    5. click on reset the drop-down list printing system

    6. we may request for Mac ID and color wheel for a while until the printer is deleted

    To re-add the printer:

    1. click on the Apple in the top left of the computer icon

    2. click on System Preferences

    3. click on printers and Scanners

    4. click on the plus sign (+) icon in the list of printers

    5 Select your printer

    6. choose HP ENVY 7640 series in the drop-down list next to 'use' or 'print using '.

    7. click on add

    If please, after back and let me know if it works for you!

  • How can I Albums in the Photo App with images taken at different times.

    How can I Albums in the Photo App with images taken at different times.

    I had books in Aperture and iPhoto which have been labeled 'Family', 'Friends', etc., and I would like to move the images in the album, and there no matter when it was taken.

    Thank you

    Brian

    In the same way. Make an Album and drag the images to him. Key word or images and the use of the smart Albums.

  • is it possible to tell me how I can make program in labview that take black and with image pixels and give the coordinates of black or white pixels again to me.

    Hello everyone

    is it possible to tell me how I can make program in labview that take black and with image pixels and give the coordinates of black or white pixels again to me.

    It depends on the image and the module LabVIEW available to you. LabVIEW can open bitmap and png files and convert them into tables: if it's really a monochromatic (depth of 1 bit) you get a table 2D boolean, T for white, F for black. Just look at the index of the item to its details (don't forget that LabVIEW does not use the order of rows and columns, so you must transpose and reflect the table). If you have a 24 bit bitmap, the table will contain the color in hexadecimal synthesis (000000 for black, FFFFFF is white and so on); Yet once, you simply check if the element of the array correspond to your requirements and get its index.

    With the vision that you module con open other pictures and perform advanced on them without convert them into tables. Anyway, you can just type the extension of your image using LabVIEW and see what you get.

    Here is a code snippet to open a monochromatic image

  • I - Phone video sent to me to my grandchildern, are on the side. I would like to 'spin' as I am able to do with images

    I - Phone video sent to me to my grandchildern, are on the side. I want to 'spin' as I am able to do with images. I can't find any opportunity to 'change' on the videos. Does anyone have a solution? Thank you

    Hi SandyTurkington,

    ·         What version of Windows is installed on your computer?

    ·         What application you're using to play the video file?

    ·         What is the file format of the video file?

    You have this option to rotate a video in Windows Live Movie Maker. If you have not installed Windows Live Movie Maker, you can follow the link below and install Movie Maker:

    http://windowslive.com/desktop/MovieMaker

    Once you download and install Windows Live Movie Maker, you can follow the steps below to rotate and save the video:

    You can turn video clips in Windows Movie Maker by following these steps:

    a. import the video clip in Windows Movie Maker.

    b. drag the imported video clip and drop it on the timeline.

    c. on the Tools menu, click Video Effects.

    d. to rotate the clip to the right, drag the effect video rotation 90 and drop it on the movie in the timeline.

    -or-

    To rotate the video clip on the left, drag the video effect rotate 270 and drop it on the movie in the timeline.

    e. on the file menu, click on the video file and follow the instructions of the wizard movie recording.

    Hope this information helps.

  • Why do I get emails intended for person with completely different e-mail address?

    Why do I get emails intended for person with completely different e-mail address? some of the Emails are addressed to names nowhere near the same spelling to my address and I always get them

    You CAN receive email if your email is added to the BCC list [1].

    Most spammers use this medium to spam others.

    [1] http://en.wikipedia.org/wiki/Blind_carbon_copy

    See you soon!

  • I continue to receive emails with images that do not appear?

    Hello

    I continue to receive emails with images that do not display, simply to show a Red Cross in the top left box from where the image should appear. I can download that will automatically open these emails?

    At soon AL

    Since it is a XP forum... I'm guessing that you are running Outlook Express?

    The following steps may be worth a try...

    Open Outlook Express and go to...

    Tools / Options / Security tab.

    Clear (clear) the box "block images and other external content in HTML e-mail" / apply / OK

    Also on the reading tab... Make sure that "Read all messages in plain text" is not checked.

  • Replace the text box with Image through breakpoints

    Hello

    I'm looking to replace the text boxes and icons with images and want to know if I can do this on several break points at the same time without having to go and manually change each breakpoint.

    My site is here: Movement of Boulder

    In the Services section of the wider breakpoint, you can see the images that I want, but if you minimize the browser window, you will see the images and the text that he was supposed to replace. Is it possible to replace all the text boxes with the images you want?

    Hello griffinb,

    If you delete a breakpoint text areas, they will be removed from all.

    After you have placed your image just right-click on it and select the option ' copy the style and position > to other breakpoints.

    Let me know if you have any problems getting there.

    Kind regards

    Ankush

  • Delivery in 29.97, work with images 23.976

    Hello.  I saw countless messages on forums and Google about mixing framerates in Premiere Pro, which is really convenient, but nobody seems to have the same scenario that I have - or at least I don't him didn't.  I must deliver a series to a broadcaster and it is made of 23.976.  I need deliver 29.97.  At the beginning I was going to cut into 23.976 and do the math so that my advertising breaks and the total length will be correct once converted to 29.97 in the online phase.  But I noticed that if you cut 23.976 images in a 29.97 timeline, seems to convert the images correctly, adding menu drop-down.  I took 00:07:29:00 to a short promo that I made in a single sequence 23.976 and copied into a new sequence of 29.97.  Duration changed to 00:07:29:14, saying my that the drop down menu has been added.

    What is the correct way to work with images 23.976 to 29.97 for broadcast deliver?

    I am using first Pro CC 2015.

    Dan

    Hi Dan, I can tell you our experience with the same situation, and you can take from it what you want:

    We turn 23.976 for a show which broadcasts 29.97i. We cut in 29.97 from end to end. This decision came from our supervisor of the position, and as she had the experience & wisdom to deliver many shows that I put total faith in this decision. She also asked our sound message and the adjustment of colours - we wanted to be on the same page, through the post. Visually, it's the same thing, so I see no advantage in cutting to the native framerate especially when it might spoil your time of calculations.

    Premiere Pro will apply the correct pulldown when you drop 23.976 frames in a 29.97 sequence, there is no problem. It will tax your native machine a little more reading, but on our machines (new iMac, Mac Pro, Macbook Pro) with Thunderbolt RAIDs there is no hiccups or falling out of the frames. The ONLY question is if you deliver 29.97 INTERLACED (not progressive), which you probably don't have. You must have your sequence value interlaced (top field) BEFORE your final export. If you cut progressive only pass interlacing in the output, then it will not have good pace. We went through this network and had an episode kicked back by QC for this reason.

    HTH,

    JVK

  • Replace values with image using DECODE

    I am struggeling to replace the values in a table with images using DECODE, as shown here'https://apex.oracle.com/pls/otn/f?p=21195:1:0:.

    The query itself is no problem and works great:

    SELECT JOB_NAME Job status, DECODE(ENABLED, 'TRUE', '<img src="/i/orcl/up.gif">', 'FALSE', '<img src="/i/orcl/down.gif">') AS

    OF USER_SCHEDULER_JOBS

    Easy as pie, but...

    Somewhere along the line the support < and > are replaced by & lt; and & gt; and the quote with & quot;

    "As a result, the browser displays literally < img src="/i/orcl/up.gif "> and no image.

    What I'm doing wrong?

    635160df-de20-4FE3-9807-b51b06b91919 wrote:

    Please update your forum profile with a real handle instead of '635160df-de20-4fe3-9807-b51b06b91919 '.

    Somewhere along the line of the support < and=""> are replaced by < and > and quotes with '. '.

    Therefore, the browser displays literally and no image.

    What I'm doing wrong?

    The column attribute the text to display as should be the Standard report column rather than the default display text (escape special characters).

  • Is it possible that I can have a spindle of pinterest this button that only appears to fly into a rectangle with image fill?

    Is it possible that I can have a spindle of pinterest this button that only appears to fly into a rectangle with image fill? In any case for also not having to add each individual image, but all the photos on the page would have a?

    The code is not in the head section, but in the body section. Try to paste the code in the html body and test it again. Sick it works. I couldn't make it work for rectangle with image fill, but it works for images.

  • Copy of complete site. I have a Web site. I would copy the entire site (complete with images) to another directory with a different name. Then, transfer to another hosting server. All ideas

    Copy of complete site. I have a Web site. I would copy the entire site (complete with images) to another directory with a different name. Then, transfer to another hosting server. Any ideas?

    Not sure that you need a different directory.

    If you are working on a local computer, create a new site with all the same settings for local files and change the remote server settings to match the second server.

    This ensures you that there is no difference between the two websites.

Maybe you are looking for

  • How to change the function FN + ALT ALT only keys

    Hello! IM wondering how to disable function key with a simple press of the contraption.For example, if I want to close a program I have to press FN + ALT + F4 keys.I hope that it is just ALT + F4.

  • Skype UI issues after upgrade to 6.10

    Hello My self to put Skype to date. Now he has problems in the user interface. See the sreenshot attached. It contains all the error messages and text that is avaiable in Skype desktop client

  • Aspire 8942G. The on screen volume level display has stopped working.

    When I use the wheel of volume on the keyboard, I would see a numerical value on screen from 0-100 indicating the volume level.  It has stopped working.  The volume and the volume in the taskbar icon work properly.  Any ideas on how to solve this pro

  • Impossible to install flash!

    Why adobe flash is installed not on my Vista 32 bit? It seems to be listed under installed programs, but no size is listed. I did everything suggested in the FAQ of Flash files.

  • Personal safety

    is Personal Security, a bogus company or a scam, and if we agree to this how get rid us of it