BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/index.php)
-   Developer Forum (http://www.blackberryforums.com/forumdisplay.php?f=15)
-   -   Showing an error (http://www.blackberryforums.com/showthread.php?t=252745)

salassi 08-26-2011 07:18 AM

Showing an error
 
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

hrbuckley 08-26-2011 07:30 AM

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.

kewal 08-29-2011 05:20 AM

Re: Showing an error
 
First seperate CustomButtonField class from mainscreen class.
dn call it in mainscreen.


All times are GMT -5. The time now is 03:04 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.