BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 09-03-2010, 08:31 AM   #1 (permalink)
New Member
 
SergioTapia's Avatar
 
Join Date: Aug 2010
Model: 7100T
PIN: N/A
Carrier: asdfasdf
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Talking Custom buttons not showing up on the form.

Please Login to Remove!

I'm creating a simple blackberry application for testing purposes and my custom buttons do not show on the UI of the simulator.

I've created a custom button called CustomButtonField and here is the code:

Code:
package test.expense;
    
    import net.rim.device.api.ui.Field;
    import net.rim.device.api.ui.Graphics;
    
    public class CustomButtonField extends Field {
    	String label;
    	int backgroundColor;
    	int foregroundColor;
    	
    	public CustomButtonField(String label, int backgroundColor, int foregroundColor, long style){
    		super(style);
    		this.label = label;
    		this.backgroundColor = backgroundColor;
    		this.foregroundColor = foregroundColor;
    	}
    	
    	public int getPreferedHeight(){
    		return getFont().getHeight() + 8;
    	}
    	
    	public int getPreferedWidth(){
    		return getFont().getAdvance(label) + 8;
    	}
    
    	protected void layout(int width, int height) {
    		setExtent(Math.min(width, getPreferredWidth()), Math.min(height, getPreferredHeight()));
    	}
    
    	protected void paint(Graphics graphics) {
    		graphics.setColor(backgroundColor);
    		graphics.fillRoundRect(1, 1, getWidth()-2, getHeight()-2, 12, 12);
    		graphics.setColor(foregroundColor);
    		graphics.drawText(label, 4, 4);
    	}
    
    }
And here is where I invoke it and display it:

Code:
HorizontalFieldManager buttonManager = new HorizontalFieldManager(FIELD_RIGHT);
    CustomButtonField btnCancel;
    CustomButtonField btnSubmit;
    
    public ExpenseSheetScreen() {
    	super();
            btnCancel = new CustomButtonField("Cancel", Color.WHITE, 0x716eb3, 0);
    	btnCancel.setChangeListener(this);
    	btnSubmit = new CustomButtonField("Submit", Color.WHITE, 0x716eb3, 0);
    	btnSubmit.setChangeListener(this);
    	
    	buttonManager.add(btnCancel);
    	buttonManager.add(btnSubmit);
    
    	add(buttonManager);
    }// End Expense Sheet Screen.
What am I doing wrong?
Offline  
Old 09-03-2010, 08:52 AM   #2 (permalink)
New Member
 
SergioTapia's Avatar
 
Join Date: Aug 2010
Model: 7100T
PIN: N/A
Carrier: asdfasdf
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I also get this error if it's any help:

Packaging project TecExpenseSheet
C:\Users\Sergio.Tapia\Desktop\Blackberry\eclipse-java-helios-win32\eclipse\plugins\net.rim.ejde.componentpack5. 0.0_5.0.0.25\components\bin\rapc.exe -quiet codename=deliverables\Standard\5.0.0\TecExpenseShe et deliverables\Standard\5.0.0\TecExpenseSheet.rapc -sourceroot=C:\Users\Sergio.Tapia\workspace\TecExpe nseSheet\src;C:\Users\Sergio.Tapia\workspace\TecEx penseSheet\res -import=C:\Users\Sergio.Tapia\Desktop\Blackberry\ec lipse-java-helios-win32\eclipse\plugins\net.rim.ejde.componentpack5. 0.0_5.0.0.25\components\lib\net_rim_api.jar C:\Users\Sergio.Tapia\workspace\TecExpenseSheet\bi n

C:\Users\Sergio.Tapia\workspace\TecExpenseSheet\sr c\tec\expense\CustomButtonField.java:24: Warning!: method 'tec.expense.CustomButtonField.getPreferedHeight() ' not invoked.

C:\Users\Sergio.Tapia\workspace\TecExpenseSheet\sr c\tec\expense\CustomButtonField.java:28: Warning!: method 'tec.expense.CustomButtonField.getPreferedWidth()' not invoked.

Packaging project TecExpenseSheet succeeded (took 2.601 seconds)
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

VINTAGE 11-R PETERSEN VISE GRIP / C - CLAMP IN ORIGINAL ORANGE BOX
$24.99
VINTAGE 11-R PETERSEN VISE GRIP / C - CLAMP IN ORIGINAL ORANGE BOX pictureVINTAGE 1904 STUDEBAKER First Gas Motor Car Co Letterpress printers block / cut
$14.99
VINTAGE 1904 STUDEBAKER First Gas Motor Car Co Letterpress printers block / cut pictureVintage NOS Allis Chalmers-VICTOR Head Gasket Set-Fits H3-RT40-D12-D14-D15-D10
$4.99
Vintage NOS Allis Chalmers-VICTOR Head Gasket Set-Fits H3-RT40-D12-D14-D15-D10 pictureVintage Original Cast Iron Horse Drawn Corn Planter Plates (Lot of 4)
$19.99
Vintage Original Cast Iron Horse Drawn Corn Planter Plates (Lot of 4) picture54282 VINTAGE SEARS CRAFTSMAN WELDING TORCH PROPANE MAPP gas & OXYGEN
$10.0
54282  VINTAGE SEARS CRAFTSMAN WELDING  TORCH PROPANE MAPP gas & OXYGEN picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.