StringIndexOutOfBoundsException when editing FormattedText [message #56618] |
Mon, 28 July 2008 16:16  |
Eclipse User |
|
|
|
Originally posted by: java14.cshg.com.br
Hi im having some trouble using FormattedText for formatting number fields
in a Eclipse RCP application .
The code involving the text fields looks like this :
FormattedText formatterText = new FormattedText(textField); ;
Locale.setDefault(Locale.US);
formatterTextField.setFormatter(new
NumberFormatter("-##########0.00"));
When I look into the text fields (executing the aplication) they work fine
but if I input a number ( ex: 125.23 ) select it using the mouse or SHIFT
key and press a number key replacing it or deleting the contents of the
field using backspace I get a out of bounds exception comming from
TextObservableValue , heres a stacktrace :
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at java.lang.String.substring(Unknown Source)
at
org.eclipse.jface.internal.databinding.swt.TextObservableVal ue$2.verifyText(TextObservableValue.java:140)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:249)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
at org.eclipse.swt.widgets.Text.verifyText(Text.java:1974)
at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1454)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036 )
at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1352)
at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3894)
at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2083)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3787 )
at org.eclipse.swt.widgets.Text.windowProc(Text.java:2078)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528 )
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:23 70)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3420)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at br.com.griffo.hgrcp.application.Application.start(Applicatio n.java:27)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Is this a know bug ??
|
|
|
|
Re: StringIndexOutOfBoundsException when editing FormattedText [message #56779 is a reply to message #56618] |
Wed, 30 July 2008 10:42  |
Eclipse User |
|
|
|
Hi,
I am somehow find your example confusing because I don't know what kind
of objects formatterTextField and textField are exactly.
I also couldn't reproduce the error.
I am taking a few assumptions here: textField is a (SWT)Text widget,
formatterTextField isn't necessary imho.
Try it with the following code instead:
FormattedText textField = new FormattedText(shell, SWT.SINGLE |
SWT.BORDER); //instead of Text textfield = ...; use whatever parent &
style you used for the Text widget
NumberFormatter formatter = new NumberFormatter("#,###,###.00", Locale.US);
textField.setFormatter(formatter);
Good Luck!
greetings
Peter
Nelson Fernando wrote:
> Hi im having some trouble using FormattedText for formatting number fields
> in a Eclipse RCP application .
>
>
> The code involving the text fields looks like this :
>
>
> FormattedText formatterText = new FormattedText(textField); ;
> Locale.setDefault(Locale.US);
> formatterTextField.setFormatter(new
> NumberFormatter("-##########0.00"));
>
> When I look into the text fields (executing the aplication) they work fine
> but if I input a number ( ex: 125.23 ) select it using the mouse or SHIFT
> key and press a number key replacing it or deleting the contents of the
> field using backspace I get a out of bounds exception comming from
> TextObservableValue , heres a stacktrace :
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at java.lang.String.substring(Unknown Source)
> at java.lang.String.substring(Unknown Source)
> at
> org.eclipse.jface.internal.databinding.swt.TextObservableVal ue$2.verifyText(TextObservableValue.java:140)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:249)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
> at org.eclipse.swt.widgets.Text.verifyText(Text.java:1974)
> at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1454)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036 )
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1352)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3894)
> at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2083)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3787 )
> at org.eclipse.swt.widgets.Text.windowProc(Text.java:2078)
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:23 70)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3420)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at br.com.griffo.hgrcp.application.Application.start(Applicatio n.java:27)
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>
>
> Is this a know bug ??
>
>
|
|
|
Re: StringIndexOutOfBoundsException when editing FormattedText [message #591345 is a reply to message #56618] |
Tue, 29 July 2008 14:44  |
Eclipse User |
|
|
|
I have the same problem.
Somebody can give some light about this issue?
Thanks in advance.
Marcelo
"Nelson Fernando" <java14@cshg.com.br> escreveu na mensagem
news:g6l9ft$rs9$1@build.eclipse.org...
> Hi im having some trouble using FormattedText for formatting number fields
> in a Eclipse RCP application .
>
>
> The code involving the text fields looks like this :
>
>
> FormattedText formatterText = new FormattedText(textField); ;
> Locale.setDefault(Locale.US);
> formatterTextField.setFormatter(new
> NumberFormatter("-##########0.00"));
>
> When I look into the text fields (executing the aplication) they work fine
> but if I input a number ( ex: 125.23 ) select it using the mouse or SHIFT
> key and press a number key replacing it or deleting the contents of the
> field using backspace I get a out of bounds exception comming from
> TextObservableValue , heres a stacktrace :
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at java.lang.String.substring(Unknown Source)
> at java.lang.String.substring(Unknown Source)
> at
> org.eclipse.jface.internal.databinding.swt.TextObservableVal ue$2.verifyText(TextObservableValue.java:140)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:249)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
> at org.eclipse.swt.widgets.Text.verifyText(Text.java:1974)
> at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1454)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036 )
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1352)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3894)
> at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2083)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3787 )
> at org.eclipse.swt.widgets.Text.windowProc(Text.java:2078)
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:23 70)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3420)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at br.com.griffo.hgrcp.application.Application.start(Applicatio n.java:27)
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>
>
> Is this a know bug ??
>
|
|
|
Re: StringIndexOutOfBoundsException when editing FormattedText [message #591361 is a reply to message #56618] |
Wed, 30 July 2008 10:42  |
Eclipse User |
|
|
|
Hi,
I am somehow find your example confusing because I don't know what kind
of objects formatterTextField and textField are exactly.
I also couldn't reproduce the error.
I am taking a few assumptions here: textField is a (SWT)Text widget,
formatterTextField isn't necessary imho.
Try it with the following code instead:
FormattedText textField = new FormattedText(shell, SWT.SINGLE |
SWT.BORDER); //instead of Text textfield = ...; use whatever parent &
style you used for the Text widget
NumberFormatter formatter = new NumberFormatter("#,###,###.00", Locale.US);
textField.setFormatter(formatter);
Good Luck!
greetings
Peter
Nelson Fernando wrote:
> Hi im having some trouble using FormattedText for formatting number fields
> in a Eclipse RCP application .
>
>
> The code involving the text fields looks like this :
>
>
> FormattedText formatterText = new FormattedText(textField); ;
> Locale.setDefault(Locale.US);
> formatterTextField.setFormatter(new
> NumberFormatter("-##########0.00"));
>
> When I look into the text fields (executing the aplication) they work fine
> but if I input a number ( ex: 125.23 ) select it using the mouse or SHIFT
> key and press a number key replacing it or deleting the contents of the
> field using backspace I get a out of bounds exception comming from
> TextObservableValue , heres a stacktrace :
>
> java.lang.StringIndexOutOfBoundsException: String index out of range: -1
> at java.lang.String.substring(Unknown Source)
> at java.lang.String.substring(Unknown Source)
> at
> org.eclipse.jface.internal.databinding.swt.TextObservableVal ue$2.verifyText(TextObservableValue.java:140)
> at
> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListe ner.java:249)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
> at org.eclipse.swt.widgets.Text.verifyText(Text.java:1974)
> at org.eclipse.swt.widgets.Text.sendKeyEvent(Text.java:1454)
> at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036 )
> at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1352)
> at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3894)
> at org.eclipse.swt.widgets.Text.WM_CHAR(Text.java:2083)
> at org.eclipse.swt.widgets.Control.windowProc(Control.java:3787 )
> at org.eclipse.swt.widgets.Text.windowProc(Text.java:2078)
> at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528 )
> at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
> at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:23 70)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3420)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2382)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:21 98)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:488)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at br.com.griffo.hgrcp.application.Application.start(Applicatio n.java:27)
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:382)
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 549)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
>
>
> Is this a know bug ??
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03323 seconds