Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6938355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:28:59+00:00 2026-05-27T12:28:59+00:00

In my application I’m using custom fields, with set*** methods wich changes some parameters

  • 0

In my application I’m using custom fields, with “set***” methods wich changes some parameters of this fields (background image, for example). thay work allmost fine, only one problem: I’m setting and changing parameters of this fields like below:

    record = new UIButton("RECORD", Field.FOCUSABLE, kButtonWidth/3-5, kButtonHeight);
    vfm2.add(Record); //I tryed this befor setters and after: no different
    record.setBackgroundImage("buttonDark.png", "buttonDark.png", "buttonDark.png");
    record.setTitleFontSize(Display.getHeight()/40);
    record.setTitle("RECORD");

When the screen with this fields are pushed, my field looks like no setters were called (but it was: I checked this via log messages). Field’s state refreshes only after it is focused (I’m calling same setters on onFocus and on onUnFocus, where I have invalidate()). Is there any way to refrash it on screen appear? In iPhone SDK, for example, there is viewDidAppear method, that colled when view(screen) did appear. Is there any same in blackberry? Or any other solution?


Here is my code of UIButton class:

public class UIButton extends Field 
{       
    private String title = null;
    private Font font;
    private int fontSize;
    private int color;
    private int horizontalAligment;
    private int state;  //0 - normal;   1 - focused;    2 - HightLighted;

    private int height;
    private int width;

    private EncodedImage currentPicture;
    private EncodedImage onPicture;
    private EncodedImage offPicture;
    private EncodedImage lightPicture;

    public UIButton(long style, int Widgh, int Height)
    {
        super(style);

        height = Height;
        width = Widgh;
        fontSize = Display.getHeight()/20;
        FontFamily ff = getFont().getFontFamily();
        font = ff.getFont(0, fontSize);
        title = "";
        color = Color.WHITE;
        state = 0;
        horizontalAligment = DrawStyle.HCENTER;

        onPicture = offPicture = lightPicture = EncodedImage.getEncodedImageResource("buttonDark.png");
        currentPicture = offPicture;

    }

    public String getTitle()
    {
        return title;
    }

    public void setTitleColor (int Color) {
        color = Color;
        invalidate();
    }

    public void setFrame (int Height, int Width) {
        height = Height;
        width = Width;
        invalidate();
    }

    public void setTitle (String Title) {
        title = Title;
        invalidate();
    }

    public void setTitleHorizontalAligment (int hAligment) {
        horizontalAligment = hAligment;
        invalidate();
    }

    public void setBackgroundImage (String forStateNurmal, String forStateFocused, String forStateHightlighted) {
        onPicture = EncodedImage.getEncodedImageResource(forStateFocused);
        offPicture = EncodedImage.getEncodedImageResource(forStateNurmal);
        lightPicture = EncodedImage.getEncodedImageResource(forStateHightlighted);
        invalidate();
    }

    public void setState (int State) {
        state = State;
        switch (state) {
        case 0: {
            currentPicture = offPicture;
            invalidate();
            break;
        }
        case 1: {
            currentPicture = onPicture;
            invalidate();
            break;
        }
        case 2: {
            currentPicture = lightPicture;
            invalidate();
            break;
        }
        }
    }

    public void setTitleFont (Font Font) {
        font = Font;
        invalidate();
    }

    public void setTitleFontSize (int FontSize) {
        fontSize = FontSize;
        FontFamily ff = font.getFontFamily();
        font = ff.getFont(0, fontSize);
        invalidate();
    }

    public int getPreferredHeight() 
    {
        return height;
    }

    public int getPreferredWidth() 
    {
        return  width;
    }


    protected void onFocus(int direction) 
    {
        super.onFocus(direction);
        this.setState(0);
    }


    protected void onUnfocus() 
    {
        if (state!=2) this.setState(1);
    }


    protected void drawFocus(Graphics graphics, boolean on) 
    {
        super.drawFocus(graphics, on);
    }


    protected void layout(int width, int height) 
    {
        setExtent(getPreferredWidth(),getPreferredHeight());
    }


    protected void paint(Graphics graphics) 
    {
        ResizeImage r = new ResizeImage();
        currentPicture = r.sizeImage(currentPicture, width-2, height-2);
        graphics.drawBitmap(1, 1, width-2, height-2, currentPicture.getBitmap(), 0, 0);
        if (title.getBytes().length>0) {

            graphics.setColor(color);
            graphics.setFont(font);

            int x = 0;
            if (horizontalAligment == DrawStyle.LEFT) x = 2;
            graphics.drawText(title, x, (height-font.getHeight())/2, 
                    (int)( getStyle() & DrawStyle.VCENTER & horizontalAligment | DrawStyle.HALIGN_MASK ), width );
        }
    }

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

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:29:00+00:00Added an answer on May 27, 2026 at 12:29 pm

    You forgot to change currentPicture in setBackgroundImage(). Try currentPicture = offPicture
    or call this.setState(0) in setBackgroundImage().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Application stores configuration data in custom section of configuration file. This information is used
Application has 7-8 activities, so I have create an application with some background music
Application has an auxiliary thread. This thread is not meant to run all the
Application is asp.net MVC. I want to put a textbox for date using mask.
Application : HTA (therefore IE) This is an application that uses SendKeys to populate
Application[temp] = 8; should set the value 8 to the key temp . However,
Application-Stack: Rails3, CanCan, Devise, Shoulda I've got some nested Resources and want to test
Application I am developing does some kind of server-side authorization. Communication is done via
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
Application: This is a workshop proposal system for a conference. A user can create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.