BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 08-26-2011, 07:18 AM   #1 (permalink)
New Member
 
Join Date: Aug 2011
Model: 8310
PIN: N/A
Carrier: Rogers
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
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 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
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 (permalink)
Knows Where the Search Button Is
 
Join Date: Mar 2011
Model: 8900
PIN: N/A
Carrier: airtel
Posts: 29
Post Thanks: 1
Thanked 0 Times in 0 Posts
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

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

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

OEM CPU FAN & HEATSINK 14R0011 TSQC0039003--IBM SURE POS 4840-563 TOUCH SCREEN
$3.99
OEM CPU FAN & HEATSINK 14R0011 TSQC0039003--IBM SURE POS 4840-563 TOUCH SCREEN pictureTwo Ribbons & 1 Lift-off tapes 1 IBM Genuine OEM Wheelwriter Typewriter 1380999
$48.17
Two Ribbons & 1 Lift-off tapes 1 IBM Genuine OEM Wheelwriter Typewriter 1380999 pictureOEM IBM SurePOS 700 4800-743/783 250W Power Supply DPS-250AB-45A 46N1999 46N1998
$27.0
OEM IBM SurePOS 700 4800-743/783 250W Power Supply DPS-250AB-45A 46N1999 46N1998 pictureOEM IBM Wheelwriter 5 Part: Paper Release Lever & Bellcrank
$1.99
OEM  IBM  Wheelwriter 5 Part:  Paper Release Lever & Bellcrank pictureGenuine OEM IBM Cartridge Wheelwriter Printwheel Script 12 #1353778
$24.95
Genuine OEM IBM Cartridge Wheelwriter Printwheel Script 12 #1353778 picture






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