BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 08-09-2007, 12:44 AM   #1
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
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, 01:31 AM   #2
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
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, 02:07 AM   #3
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
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, 08:05 AM   #4
arifzaman
Thumbs Must Hurt
 
Join Date: Jun 2007
Location: Bangladesh
Model: 8800
PIN: N/A
Carrier: EDGE
Posts: 93
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, 09:14 AM   #5
rock_win
Knows Where the Search Button Is
 
Join Date: Aug 2007
Model: 8100
PIN: N/A
Carrier: cingular
Posts: 33
Default

Hi Arif

thats a nice observation for platforms.

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


Retro 1951 Apple Computer Logo 0.7mm Ballpoint Black Ink Pen Gold Barrel picture

Retro 1951 Apple Computer Logo 0.7mm Ballpoint Black Ink Pen Gold Barrel

$56.41



C2102A-4 INTEL VINTAGE 1K SRAM 1024Bit CERAMIC GOLD PINS APPLE 1, DC1976 Mimeo-1 picture

C2102A-4 INTEL VINTAGE 1K SRAM 1024Bit CERAMIC GOLD PINS APPLE 1, DC1976 Mimeo-1

$30.83



Lot of 6 Vintage Apple Drawstring Bags For iPhone, Mac, Apple Watch, iPod picture

Lot of 6 Vintage Apple Drawstring Bags For iPhone, Mac, Apple Watch, iPod

$45.00



Vintage Food Cut-Out Display Print: Mama's Apple Pie w/Ice Cream Topper picture

Vintage Food Cut-Out Display Print: Mama's Apple Pie w/Ice Cream Topper

$19.00



Vintage Print Block “ Apple Corer Kitchen Tool “ Copper Face Block picture

Vintage Print Block “ Apple Corer Kitchen Tool “ Copper Face Block

$16.00



Vintage  Rainbow Logo Apple Post-It Sticky Notes 4

Vintage Rainbow Logo Apple Post-It Sticky Notes 4" Rare computer collectible

$39.99







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