Drawing RoundRect form of a customLabel does not form roundRect

Hello

I create a custom label field that was created successfully.

Now, after that in order to have a round shape for this label in paint (Graphics graphics) I paint a roundRect and then again the label content (image and and a textString) top.

Yes I also have round titled form using the method setBorder (RoundBorder) (I tried it and it works ), but I tried it as follows.

public class CustomField extends Field {

    private String mLabelText = null;
    private int mForegroundColor = 0;
    private int mBackgroundColor = 0;
    private Bitmap mBitmap = null;

    public CustomField(long style, String iLabelText, int iForegroundColor,
            int iBackgroundColor) {
        super(style);
        mLabelText = iLabelText;
        mForegroundColor = iForegroundColor;
        mBackgroundColor = iBackgroundColor;
    }

    public CustomField(Bitmap iBitmap, long style, String iLabelText,
            int iForegroundColor, int iBackgroundColor) {
        this(style, iLabelText, iForegroundColor, iBackgroundColor);
        mBitmap = iBitmap;
    }

    protected void layout(int width, int height) {

        if ((getStyle() & Field.USE_ALL_WIDTH) == Field.USE_ALL_WIDTH) {
            setExtent(width, Math.min(height, getPreferredHeight()));
        } else {
            setExtent(getPreferredWidth(),
                    Math.min(height, getPreferredHeight()));
        }
    }

    protected void paint(Graphics graphics) {

        graphics.drawRoundRect(0, 0, getWidth(), getHeight(),
                20  , 20);


        graphics.setBackgroundColor(mBackgroundColor);
        graphics.clear();
        graphics.setFont(Font.getDefault().derive(Font.SANS_SERIF_STYLE, 25,
                Ui.UNITS_px, Font.ANTIALIAS_NONE, Font.COLORED_OUTLINE_EFFECT));
        graphics.setColor(mForegroundColor);

        if (mBitmap != null) {
            int textHeight = (getHeight() - getFont().getHeight()) / 2;
            int imageHeight = (getHeight() - mBitmap.getHeight()) / 2;
            graphics.drawBitmap(0, imageHeight, mBitmap.getWidth(),
                    mBitmap.getHeight(), mBitmap, 0, 0);
            graphics.drawText(mLabelText, mBitmap.getWidth(), textHeight,
                    DrawStyle.ELLIPSIS, getWidth() - mBitmap.getWidth());
        } else {
            graphics.drawText(mLabelText, 0, 0, DrawStyle.ELLIPSIS, getWidth());
        }
    }

    public int getPreferredHeight() {
        if (mBitmap != null) {
            return Math.max(mBitmap.getHeight(), getFont().getHeight());
        } else {
            return getFont().getHeight();
        }
    }

    public int getPreferredWidth() {

        int width = getFont().getAdvance(mLabelText);
        if (mBitmap != null) {
            width += mBitmap.getWidth();
        }
        return width;
    }

}

I use for creating label second constructor(which one with a content Bitmap);

Can any body tell please where I am wrong? I did try a range of values for arcWidth and arcHeight params to the drawRoundRect() method, but not round rectangle (rectangular plain).

Thank you

OK I got it, the problem was in the method object

I was drawing Rect before calling clear(). Now, I got the rounded shape of the label.

can we set backgroundcolor to RoundRect drawn instead of field (graphics object)?

Tags: BlackBerry Developers

Similar Questions

  • Satellite C850 - draw of disk does not work

    The draw of a Toshiba C850 drive does not open

    It must me very small hole near the eject button.
    In case you are unable to eject the disc, you should try to insert a paper clip into this hole in order to eject the optical drive open

  • Illustrator CC 2015 unusable? (Leaving unexpectedly or does not show the work plans)

    For some reason any work plans are not displayed after that I opened a new document in the new Version of Ai. When I then draw a rectangle of base it does not show.
    Work plans are activated - so
    'NO' I didn't just turn them off.


    Screen Shot 2015-06-17 at 11.34.58.png



    When I restart HERE it just closes unexpectedly...

    Screen Shot 2015-06-17 at 11.38.42.png

    I just can't use right now and I really need work. Unfortunately Adobe didn't about uninstalling older Versions in the cloud Crective update dialog. So I'm pretty stuck right now.

    Someone has similar problems?

    Is there any fixes for this?

    @all: it's just the 'novelty' "GPU-performance"...

    turn it off in the settings directly on the icon of the rocket in the menu bar above.

    Bugy 'novelty '...

  • Align 45 does not... Some opinions, I cannot draw a line at 45 and 90 degree angle with a line (for example to draw a straight line with SHIFT tool, select and line maintenance, form does not hang at increments of 45 as it was by default) it Note still wo

    Align 45 does not... Just noticed I can't align a line at 45 and 90 degree angle with a line (for example to draw a straight line with SHIFT tool, select and maintaining line, shape is not hang at increments of 45 as it was by default) it notes still works with forms & text etc, but not with a straight line. Having downloaded the latest January 14, 2016

    Last update fixed this Glitch, Illustrator please :-)

  • HP LaserJet Pro M252dw: Won't print - HP LaserJet Pro M252dw drawer of toner cartridge does not retract

    Toner HP LaserJet Pro M252dw cartridge drawer does not retract.  The small blue drawer pull is out there is no way to open the drawer.  This flaw was not discovered until I needed toner, 5 months later - this printer was bought in January 2016 and worked well.  Now, it's just a big box of heavy using the space in my office.

    I can't be the only person with this problem printer!

    Thank you

    JQ

    Hello @jakehuesand welcome to the Forums of HP! Although I would like to help you with your M252dw, I'm not sure that I can do on one piece broken other than suggest that you call us. HP printers usually have a warranty of 1 year from the date of purchase, you can check the warranty using the following if you want to: check your warranty status.

    What you can do, is to use the following link to create yourself a file number, then call and it can help to expedite the appeal process:

    Step 1. Open the link: www.hp.com/contacthp/
    Step 2. Enter the product number or select Auto detection
    Step 3. Scroll up to "still need help? Fill out the form to select your contact options.
    Step 4. Scroll down and click on: contact HP options - click Get phone number

    File number and phone number are displayed.

    Feel free to post again if there is anything else I can help you with that.

    If my answer meets your needs, please click Accept button Solution below to report your post as solved. Thank you.

  • Is it possible to return to the synchronization of the former in Firefox, as new synchronization does not work.

    As new synchronization does not work for me, despite the setting it in total compliance with the Mozilla Web site and no one took the trouble to answer the previous post today, is it possible to return to the synchronization of the former?

    To the best of my knowledge, the synchronization of the former is no longer available.

    If you post some details on the problems you are having with the sync, we can try to solve your problem.

  • Envoy in contact form does not end in sent items

    First of all, a nice feature is what preceded this form (trying to answer my question and undo/resolve the workload of duplicate messages), where I'm typing now.

    I see two to be descriptive. Good point... but fortunately, I can be concise, and I'll get right to the point.

    My dad said that a form of contact presented in the browser does not (not) found in the sent items of the email client. Which is probably a good thing.

    It would be a good deal to represent? It is useless, but for a system administrator to do it manually. So he would probably need a script...

    )

    PS: search powerhungry Google for 'thunderbird sent form elements' (should have that in the representation of Thunderbird...); It might be good to separate the content from that of other pieces on the Web page... perhaps that Google reads. A good deal for the hubs! Or webrings as we were doing it at the time to call them. All voluntarily.

    You are trying to read through all the unwanted extra in your post, I think your question is why items sent with the web mail interface do not appear in the folder sent to Thunderbird or any other e-mail client.
    Best estimate is that you use POP email and that's how it works. POP email only interfaces with the Inbox.
    If you want all folders to synchronize you should use IMAP E-mail.
    Google that.

  • Does not restore the values of form for the restoration of the tab

    Part of my Web site uses a large number of forms on a single page. On the page, you can filter items (each item has its own form) and modify them. One entry looks like this: [name] [select status] [other Select]. Other important things are that the document has an expiration date in 1981 (to apply a page always up to date) and that change the value in the select results in the triggering of an AJAX function.

    It works perfectly, except for one thing. When filtering State id 1, you get back a little of the element. Let's say that the result of the filter are input 5. Change entry #2 status, which triggered an AJAX function. It works very well, but here's the problem: when close the tab and re-opening with Restore tab, select values become disheveled.

    Due to the execution of a fresh copy of the page, the browser will get a new copy of the page. Entry #2 is now gone (I'll keep calling it that, even if she disappeared because of the filter). Now, here's the problem: Firefox is attempting to restore the value to select it. Entry of the status #3 now has the same status of entry #2, #4 a #3 status and so on.

    I managed to solve this problem on other browsers (Chrome, IE) with this little piece of jQuery:
    {$(document) .ready (function ()}
    {$("form[class^='startingformname']").each (function ()}
    This.Reset ();
    })
    });
    It works perfectly, except for Firefox, which seems to ignore the call to reset...

    As this text is quite long, I'll keep my short question: How do you keep Firefox restore the values of the form (preferably: keep them on the selected item in the HTML)? Now, the user always gets a new copy of the page, and Firefox is trying to restore the old values on this page, even though the HTML code has changed.

    I think your two choices is:

    (1) prevent Firefox from page caching, or

    (2) use a different event to trigger your reset function

    As I understand it, the function $(document) .ready jQuery () raises the event DOMContentLoaded (or equivalent, if not supported by the browser). If the tab is cached in its ' cache fast back-forward ", Firefox can not fire this event when the user returns to the tab, just like Firefox does not always raise the load event in such cases.

    Discover the event more described in the following article and see if you can use it to trigger your reset function in Firefox: https://developer.mozilla.org/docs/Using_Firefox_1.5_caching

    Who is?

  • Auto form fill does not work in Google

    I updated Firefox to 8.0 days and everything was OK, but today I discovered this forms AutoComplete does not work in google (it works on other sites, however). I checked through form story addon that historical form has not been deleted, it's just the auto form fill that do not work. This happens on both my work and home computer. From FF in safe mode (with extensions disabled) does not help.

    It works to disable JavaScript. Or using the URL http://www.google.com/webhp?complete=0 . Kinda weird, but seems to be the issue of google anyway.

  • Notes for the drawing feature does not appear in my Mini iPad after update 9.3

    After update to 9.3 on Ipod Touch and iPad Mini (original) (generation 5), the Notes applet does not show the drawing tool in the toolbar. My age of devices is the reason for this limitation?

    Post edited by: jesternrb1

    Yes, it is, or the first generation iPad Mini: https://help.apple.com/ipad/9/#/iPada9fb7c64

    Note: The sketch feature is available with notes of upgrade on iPad Pro, iPad (4th generation and later) and mini iPad 2 and later versions. If you have the iPad Pro, you can sketch in pencil from Apple.

    or the fifth generation iPod Touch: https://help.apple.com/ipod-touch/9/#/iph1e1d28202

    Note: The drawing feature is available with upgrade on iPod touch notes (6th generation) and later versions.

    Support it

  • Firefox 4 does not save form data after sending form and pressing the previous button

    Firefox 4 does not save form data after sending form and pressing the back button... It's very annoying that it erases all data. It worked fine on FF3.

    See:

    • Firefox or tools > Options > privacy > History: "don't forget to search and form history."
  • Site Web of forms does not and cannot scroll

    Hello:

    Can please tell me how to adjust the size of the forms or Web sites when they do not fit the screen and does not allow me to finish the forms by scrolling. Sometimes, in the middle of downloading applications or programs, blocks education not loading small enough for me to click on things (the boxes are too big for the screen).

    Can you please tell me how to solve this problem.

    Sue

    You want to change the size of the browser window?
    If you use Internet Explorer, you should try to press Fn + 1 or Fn + 2
    Also you could do a zoom in and zoom out in the view that is located in the Menu bar

  • AutoComplete does not work on certain forms

    I read the help article indicated this:

    > AutoComplete does not work on certain forms

    > If you find that Firefox will save the form entries for forms on some Web sites only, but not on others, the site may be say Firefox does not save form history. This is especially common on email and Bank Web sites.

    But I want to save the information for some of these sites. How can I manually enter the information, so that Firefox it tells when I navigate? Is this possible?

    This bookmarklet makes the browser ignore autocomplete = "off" temporarily, allows to save passwords even on sites that use autocomplete = "off". Should work the same for the form data.

    Don't forget to bookmark password:
    https://www.squarefree.com/bookmarklets/forms.html#remember_password

  • Search history form does not record in the latest version of Gmail, but not in the old version

    In the latest version of Gmail, no history of search form will save, but it does in the old version of Gmail. I checked the settings to clear all history, and they are all correct, because it does not remove another story of shape, including the old version of Gmail. This happens only in the new version, that's why I continued to use the old version. I also checked for conflicts of plugin and there is not. I'm on WinXP-SP3 using the 3.6.6 latest version of Firefox.

    Gmail can use autocomplete = "off" for this form to avoid registration of form data.

    Here is a bookmarklet to check that:
    javascript:(function() }}catch(e) return(r)}R(self);var i,x;for(i=0;x=frames[i];++i)R(x); })();
    See http://en.wikipedia.org/wiki/Bookmarklet

  • Help: New pencil will work on screen for touch/scroll, but it does not write, draw or scribble...

    Help: New pencil will work on screen for touch/scroll, but it does not write, draw or scribble...

    While you do not, you use the iPad Pro, correct?

Maybe you are looking for