×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Sep 2013
    Posts
    50

    Changing the background color of a Button

    So, from what I can tell, it is not possible to change a button's background color by calling button.getStyle().setBgColor(). I've read some things about how I need to create a button in the resource editor, but I have no clue how to do this. I've poked around in the resource editor, and read some tutorials on this subject, but I'm still lost.

    How can I create a button with a custom style in the resource editor, and then access that with the setUIID() method in my app?

    Thanks!

  2. #2
    Registered User
    Join Date
    Dec 2012
    Location
    India
    Posts
    264

    Re: Changing the background color of a Button

    Hi

    I am assuming you are using LWUIT For Series 40. It uses platform colours for buttons which causes this issue.I was not able to exactly override that, but I managed to do something else which could be useful for you.I have recorded it as a video so that it will be easy for you to understand.

    First, goto the directory where you have LWUIT for S40.It is usually under "C:\Nokia\Devices\Nokia_Asha_SDK_1_0\plugins\LWUIT\lib\" directory.Extract the contents of S40 LWUIT Jar in order to get access to the THEME File.Open the theme in resource editor and follow the steps shown below to stylize a custom component.

    http://arunbalaji.in/SWF/new%20button.html

    Save the theme as new_theme.res and create a sample project in your IDE .Add S40 without Themes JAR File and the theme to your project.Copy the following code in the startApp method and check it out!The code is simple so I feel you wont have any difficulty understanding.

    Code:
            Display.init(this);
            
             try {
                 Resources r1 = Resources.open("/new_theme.res");
                 UIManager.getInstance().setThemeProps(r1.getTheme(r1.getThemeResourceNames()[0]));
             } catch (Exception ex) {
                 ex.printStackTrace();
             }
    
            Form Button_Test = new Form("Button Test");
            Button b1 = new Button("First Button");
            Button b2 = new Button("Second Button");
    
            Button b3 = new Button("Ordinary Button");
            
            b1.setUIID("New Button");
            b2.setUIID("New Button");
            
            Button_Test.addComponent(b1);
            Button_Test.addComponent(b2);
            Button_Test.addComponent(b3);
            
            Button_Test.show();

    and Here is a video about Borders : http://www.youtube.com/watch?v=A8KXMijiWgQ


    Cheers!
    Arun.

  3. #3
    Registered User
    Join Date
    Sep 2013
    Posts
    50

    Re: Changing the background color of a Button

    Thanks, I will try this!

Similar Threads

  1. problem in changing background color of listboxview!!
    By please_help in forum Symbian User Interface
    Replies: 5
    Last Post: 2012-01-09, 06:48
  2. changing background color of status pane
    By shasaad in forum Symbian User Interface
    Replies: 1
    Last Post: 2010-07-29, 02:57
  3. Changing background color Of CEikEdwin
    By swapnilb83 in forum Symbian
    Replies: 3
    Last Post: 2009-10-06, 13:55
  4. Problem in changing background color of Editor!
    By manish.agarw in forum Symbian
    Replies: 2
    Last Post: 2009-04-27, 14:47
  5. Changing the background color for the status pane...
    By prbhat in forum Symbian User Interface
    Replies: 3
    Last Post: 2009-03-09, 17:43

Posting Permissions

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