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



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


Trek 677B High Voltage Supply / Amplifier picture

Trek 677B High Voltage Supply / Amplifier

$700.00



Voice Amp Amplifier Model 200260 Scott EPIC Safety Compatible w AV3000 AV2000 picture

Voice Amp Amplifier Model 200260 Scott EPIC Safety Compatible w AV3000 AV2000

$60.00



NEW Winbridge S92 PRO Bluetth Mini Portable Rechargeable Voice Amplifier Karaoke picture

NEW Winbridge S92 PRO Bluetth Mini Portable Rechargeable Voice Amplifier Karaoke

$35.00



2pcs TDA2003 Power Amplifier CAR AUDIO12v 10w USA Seller fats shipping picture

2pcs TDA2003 Power Amplifier CAR AUDIO12v 10w USA Seller fats shipping

$4.80



FiiO BTR15 Bluetooth DAC/Amp Titanium High-Res Audio MQA, Dual Output - Titanium picture

FiiO BTR15 Bluetooth DAC/Amp Titanium High-Res Audio MQA, Dual Output - Titanium

$85.98



BJ300 Plus BJ300Plus 3-30MHz Radio Power Amplifier +Fan FM 100W AM 200W SSB 300W picture

BJ300 Plus BJ300Plus 3-30MHz Radio Power Amplifier +Fan FM 100W AM 200W SSB 300W

$104.49







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