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


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


AC 80-260V 0-100A LCD Digital Display Volt Watt Power Meter Voltmeter Ammeter picture

AC 80-260V 0-100A LCD Digital Display Volt Watt Power Meter Voltmeter Ammeter

$22.50



Analog Panel AMP VOLT Current Ammeter Voltmeter Voltage Gauge 10A 50V DH-670 DC  picture

Analog Panel AMP VOLT Current Ammeter Voltmeter Voltage Gauge 10A 50V DH-670 DC

$12.99



Battery Tester DC 0-80V0-350A SOC AH VOLT AMP Capacity Tester Voltmeter Ammeter picture

Battery Tester DC 0-80V0-350A SOC AH VOLT AMP Capacity Tester Voltmeter Ammeter

$36.50



100A AC Multimeter Power Energy Voltmeter Ammeter Open Close Current Transformer picture

100A AC Multimeter Power Energy Voltmeter Ammeter Open Close Current Transformer

$22.50



US Stock Analog Panel AMP Current Ammeter Meter Gauge DH-670 0-10A DC picture

US Stock Analog Panel AMP Current Ammeter Meter Gauge DH-670 0-10A DC

$13.23



DC 100V 100A Voltmeter Ammeter Volt Amp Meter Voltage Current Tester with Shunt picture

DC 100V 100A Voltmeter Ammeter Volt Amp Meter Voltage Current Tester with Shunt

$14.48







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