BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 08-09-2007, 01:44 AM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default ArrayIndexOutofBound Exception for Custom Field

Please Login to Remove!

Hi

i'm trying to make one of my own custom Edit field.
I'm referring to the code in the thread "Border & Basic Editfield"

where the Wikipedia interface is provided and a custom edit field, but when i try to make it bigger, by changing it width and height in the layout like:

Code:
public void layout(int width,int height)
{
setExtend(120,100);
}
it gives me the Exception,

If i remove the layout , it works fine, but i want to make it bigger in height mainly, and overrider couple of things like making it multi-line.
Offline  
Old 08-13-2007, 02:31 AM   #2 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here's the modified code of Custom Edit field, posted here earlier:
Code:
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;

public class TextEntryWidget extends EditField {
int labelColor = Color.BLACK;
Font labelFont = getFont();
int textColor = Color.BLACK;
int borderColor = Color.BLACK;
int horizontalsize = 150;
int maxChars = 30;
String text = "";
String fulltext = "";
int leftMargin = 0;
public TextEntryWidget() {
super();
}
public TextEntryWidget(long style) {
super(style);
}
public TextEntryWidget(String label, String initialValue) {
super(label, initialValue);
}
public TextEntryWidget(String label, String initialValue, int maxNumChars, long style) {
super(label, initialValue, maxNumChars, style);
maxChars = maxNumChars;
}

public void paint(Graphics graphics) {
String txt = this.getText();
graphics.setColor(textColor);
graphics.setFont(getFont());
graphics.drawText(txt, 51, 0);
graphics.setColor(borderColor);
graphics.drawRoundRect(49, 0, 150, 20, 5, 5);
}
public void drawFocus(Graphics g, boolean on) {
//
}

}

now , if i add the following to the above code, it gives me ArrayIndexOutofBoundException

Code:
public void layout(int width,int height)
{
setExtent(100,100);
}
Offline  
Old 08-13-2007, 03:07 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just to update on the findings, as it might help someone else too.

If i make a custom field by extending the Field class, then no matter what extent i use and the layout method , it works fine.

But i would very much like to use the functionalities of the EditField (code reusability) rather than write whole thing again.
Offline  
Old 08-13-2007, 09:05 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi rock_win,

Quote:
Originally Posted by rock_win View Post
public void layout(int width,int height)
{
setExtent(100,100);
}
I didn't face any problem with this code. I've used JDE 4.2.1 to build and runs on 8700g simulator.

But I do experience the same error when try to build using JDE 4.0 and runs on 7210 simulator.

This may be the cause of PLATFORM or amount of available space . I'll get back to you next time with expected point. But before that can you please send me your Environment details?


ARIF
Offline  
Old 08-13-2007, 10:14 AM   #5 (permalink)
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Arif

thats a nice observation for platforms.

I'm working on 7290 simulator, platform ver 4.0.2
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





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