BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-26-2011, 07:18 AM   #1
salassi
New Member
 
Join Date: Aug 2011
Model: 8310
PIN: N/A
Carrier: Rogers
Posts: 12
Angry Showing an error

Please Login to Remove!

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.Graphics;
import net.rim.device.api.ui.container.MainScreen;


public class CustomButScreen extends MainScreen
{

public CustomButScreen()
{
public class CustomButtonField extends Field
{

private int backgroundColour = Color.GRAY;
private int highlightColour;
private int fieldWidth;
private int fieldHeight;
private String text;
private int padding = 8;

public CustomButtonField(String text, int highlightColour)
{
super(Field.FOCUSABLE);
this.text = text;
this.highlightColour = highlightColour;
Font defaultFont = Font.getDefault();
fieldHeight = defaultFont.getHeight() + padding;
fieldWidth = defaultFont.getAdvance(text) + (padding * 2);
this.setPadding(2, 2, 2, 2);
}

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

protected void onFocus(int direction)
{
backgroundColour = highlightColour;
invalidate();
}

protected void onUnfocus()
{
backgroundColour = Color.GRAY;
invalidate();
}

public int getPreferredWidth()
{
return fieldWidth;
}

public int getPreferredHeight()
{
return fieldHeight;
}

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

protected void drawFocus(Graphics graphics, boolean on)
{

}

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

protected void paint(Graphics graphics)
{
graphics.setColor(backgroundColour);
graphics.fillRoundRect(0, 0, fieldWidth, fieldHeight, 8, 8);
graphics.setColor(Color.GRAY);
graphics.drawRoundRect(0, 0, fieldWidth, fieldHeight, 8, 8);
graphics.setColor(Color.WHITE);
graphics.drawText(text, padding - 1, padding / 2 + 1);
}
}


}

}


The above code is showing an error that the classname CustomButtonField is an invalid modifier...I didnt understand what that actually means...and what i should do to rectify...
Thanks in advance
Offline  
Old 08-26-2011, 07:30 AM   #2
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Default Re: Showing an error

First, before you post any more code please read this sticky thread.

You are declaring a nested class CustomButtonField in the outer class constructor. Move the declaration outside of the constructor.
__________________
My other Blackberry is a PlayBook.
Offline  
Old 08-29-2011, 05:20 AM   #3
kewal
Knows Where the Search Button Is
 
Join Date: Mar 2011
Model: 8900
PIN: N/A
Carrier: airtel
Posts: 29
Default Re: Showing an error

First seperate CustomButtonField class from mainscreen class.
dn call it in mainscreen.
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads for: Showing an error
Thread Thread Starter Forum Replies Last Post
Fresh Install 5.0 Remote SQL Error dvine RIM Software 0 10-12-2009 04:44 AM
Input system error - the system ..... starwatcher General 8100 Series Discussion - Pearl 7 01-30-2007 04:31 PM
CDO.DLL woes... kjohn BES Admin Corner 9 11-29-2005 10:17 AM
UPLink internal error keithc General BlackBerry Discussion 6 05-17-2005 03:24 PM
Device Error 507 (model 6280) PureShakti General BlackBerry Discussion 2 03-21-2005 03:09 PM


10 Feet/3M For iPhone 13 12 11 PRO MAX MINI  X XR XS 8 7 Fast Charging USB Cable picture

10 Feet/3M For iPhone 13 12 11 PRO MAX MINI X XR XS 8 7 Fast Charging USB Cable

$5.00



3M/10 feet Long Apple iPhone 13 12 11 Pro XS MAX XR X 8 Fast Charging Data Cable picture

3M/10 feet Long Apple iPhone 13 12 11 Pro XS MAX XR X 8 Fast Charging Data Cable

$3.50



NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch picture

NEW OEM Battery A1466 A1369 A1496 A1405 A1377 A1466 for MacBook Air 13 inch

$31.90



New Apple White Charger Cradle Docking Station Base Stand A1381 OEM picture

New Apple White Charger Cradle Docking Station Base Stand A1381 OEM

$8.50



Lot of OEM APPLE iPAD LCD And White Front Glass Replacement 6091l-1402C picture

Lot of OEM APPLE iPAD LCD And White Front Glass Replacement 6091l-1402C

$17.99



Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013 picture

Genuine A1417 OEM Battery Apple Macbook Pro 15 Retina A1398 Mid 2012 Early 2013

$40.90







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