Skip to main content

raise() and lower() methods throw exception

2 replies [Last post]
Anonymous

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Tom Ball

This sounds like a scenegraph issue.

emre onal wrote:
> I think raise() and lower() methods don't work properly. It throws
> indexoutofboundsexception at
> com.sun.scenario.scenegraph.SGGroup.add(SGGroup.java:62)
>
> Here is the sample code I tried:
>
>
> import java.lang.System;
> import javafx.ui.*;
> import javafx.ui.canvas.*;
>
>
> var a:Rect;
> a=Rect{
> x:50 y: 60
> width:50
> height: 50
> fill:Color.RED
> onMouseClicked: function(e){
> a.raise();
> }
> };
> var b:Rect;
> b=Rect{
> x:65 y:75
> width:50
> height: 50
> fill:Color.BLACK
> onMouseClicked: function(e){
> b.raise();
> }
> };
>
> var c:Rect;
> c=Rect{
> x:75 y:50
> width:50
> height: 50
> fill:Color.BLUE
> onMouseClicked: function(e){
> c.raise();
> }
> };
> Frame{
> width: 300
> height: 300
> visible:true
> content: Canvas{
> content:[a,b,c]
> }
> onClose: function() {System.exit(0);}
> }
>
>
> Here is the error message:
>
>
> init:
> deps-jar:
> Compiling 1 source file to C:\Documents and
> Settings\biz\Belgelerim\NetBeansProjects\JavaFXApplication7\build\classes
> compile:
> run-single:
> Exception in thread "AWT-EventQueue-1"
> java.lang.IndexOutOfBoundsException: invalid index
> at com.sun.scenario.scenegraph.SGGroup.add(SGGroup.java:62)
> at javafx.ui.Canvas$3.onChange(Canvas.fx:85)
> at
> com.sun.javafx.runtime.location.SequenceVariable.notifyListeners(SequenceVariable.java:176)
> at
> com.sun.javafx.runtime.location.SequenceVariable.replaceSlice(SequenceVariable.java:112)
> at
> com.sun.javafx.runtime.location.SequenceVariable.access$000(SequenceVariable.java:19)
> at
> com.sun.javafx.runtime.location.SequenceVariable$1.onReplaceSlice(SequenceVariable.java:68)
> at
> com.sun.javafx.runtime.sequence.SequenceMutator.replaceSlice(SequenceMutator.java:147)
> at
> com.sun.javafx.runtime.sequence.SequenceMutator.set(SequenceMutator.java:160)
> at
> com.sun.javafx.runtime.location.SequenceVariable.set(SequenceVariable.java:270)
> at javafx.ui.Canvas.raiseNode$impl(Canvas.fx:1)
> at javafx.ui.Canvas.raiseNode(Canvas.fx:51)
> at javafx.ui.canvas.CanvasElement.raise$impl(CanvasElement.fx:65)
> at javafx.ui.canvas.Rect.raise(Rect.fx:39)
> at Raising$2.lambda(Raising.fx:24)
> at Raising$2.invoke(Raising.fx:23)
> at Raising$2.invoke(Raising.fx:23)
> at
> javafx.ui.canvas.Node$1SGMouseAdapter$anon139.mouseClicked(Node.fx:83)
> at
> com.sun.scenario.scenegraph.SGNode.processMouseEvent(SGNode.java:372)
> at
> com.sun.scenario.scenegraph.JSGPanel$MouseInputDispatcher.deliver(JSGPanel.java:222)
> at
> com.sun.scenario.scenegraph.JSGPanel$MouseInputDispatcher.mouseClicked(JSGPanel.java:352)
> at
> com.sun.scenario.scenegraph.JSGPanel$MouseInputDispatcher.mouseClicked(JSGPanel.java:349)
> at
> java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
> at
> java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
> at
> java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
> at java.awt.Component.processMouseEvent(Component.java:6041)
> at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
> at java.awt.Component.processEvent(Component.java:5803)
> at java.awt.Container.processEvent(Container.java:2058)
> at java.awt.Component.dispatchEventImpl(Component.java:4410)
> at java.awt.Container.dispatchEventImpl(Container.java:2116)
> at java.awt.Component.dispatchEvent(Component.java:4240)
> at
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
> at
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
> at java.awt.Container.dispatchEventImpl(Container.java:2102)
> at java.awt.Window.dispatchEventImpl(Window.java:2429)
> at java.awt.Component.dispatchEvent(Component.java:4240)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
> at
> com.sun.scenario.scenegraph.SGEventQueue.dispatchEvent(SGEventQueue.java:374)
> at
> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
> at
> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
> at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
> at
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net

Jim Clarke

SGGroup.add(index, node) assumes that if the index is greater than the
current number of
children, then throw the IndexOutOfBoundsException. So either we could
fix Canvas to check for this condition, and call add(node),
when it is not within the current range, or we can fix Scenegraph to treat
1 more than the current size as "add to the end".

jim

Tom Ball wrote:
> This sounds like a scenegraph issue.
>
> emre onal wrote:
>> I think raise() and lower() methods don't work properly. It throws
>> indexoutofboundsexception at
>> com.sun.scenario.scenegraph.SGGroup.add(SGGroup.java:62)
>>
>> Here is the sample code I tried:
>>
>>
>> import java.lang.System;
>> import javafx.ui.*;
>> import javafx.ui.canvas.*;
>>
>>
>> var a:Rect;
>> a=Rect{
>> x:50 y: 60
>> width:50
>> height: 50
>> fill:Color.RED
>> onMouseClicked: function(e){
>> a.raise();
>> }
>> };
>> var b:Rect;
>> b=Rect{
>> x:65 y:75
>> width:50
>> height: 50
>> fill:Color.BLACK
>> onMouseClicked: function(e){
>> b.raise();
>> }
>> };
>>
>> var c:Rect;
>> c=Rect{
>> x:75 y:50
>> width:50
>> height: 50
>> fill:Color.BLUE
>> onMouseClicked: function(e){
>> c.raise();
>> }
>> };
>> Frame{
>> width: 300
>> height: 300
>> visible:true
>> content: Canvas{
>> content:[a,b,c]
>> }
>> onClose: function() {System.exit(0);}
>> }
>>
>>
>> Here is the error message:
>>
>>
>> init:
>> deps-jar:
>> Compiling 1 source file to C:\Documents and
>> Settings\biz\Belgelerim\NetBeansProjects\JavaFXApplication7\build\classes
>>
>> compile:
>> run-single:
>> Exception in thread "AWT-EventQueue-1"
>> java.lang.IndexOutOfBoundsException: invalid index
>> at com.sun.scenario.scenegraph.SGGroup.add(SGGroup.java:62)
>> at javafx.ui.Canvas$3.onChange(Canvas.fx:85)
>> at
>> com.sun.javafx.runtime.location.SequenceVariable.notifyListeners(SequenceVariable.java:176)
>>
>> at
>> com.sun.javafx.runtime.location.SequenceVariable.replaceSlice(SequenceVariable.java:112)
>>
>> at
>> com.sun.javafx.runtime.location.SequenceVariable.access$000(SequenceVariable.java:19)
>>
>> at
>> com.sun.javafx.runtime.location.SequenceVariable$1.onReplaceSlice(SequenceVariable.java:68)
>>
>> at
>> com.sun.javafx.runtime.sequence.SequenceMutator.replaceSlice(SequenceMutator.java:147)
>>
>> at
>> com.sun.javafx.runtime.sequence.SequenceMutator.set(SequenceMutator.java:160)
>>
>> at
>> com.sun.javafx.runtime.location.SequenceVariable.set(SequenceVariable.java:270)
>>
>> at javafx.ui.Canvas.raiseNode$impl(Canvas.fx:1)
>> at javafx.ui.Canvas.raiseNode(Canvas.fx:51)
>> at
>> javafx.ui.canvas.CanvasElement.raise$impl(CanvasElement.fx:65)
>> at javafx.ui.canvas.Rect.raise(Rect.fx:39)
>> at Raising$2.lambda(Raising.fx:24)
>> at Raising$2.invoke(Raising.fx:23)
>> at Raising$2.invoke(Raising.fx:23)
>> at
>> javafx.ui.canvas.Node$1SGMouseAdapter$anon139.mouseClicked(Node.fx:83)
>> at
>> com.sun.scenario.scenegraph.SGNode.processMouseEvent(SGNode.java:372)
>> at
>> com.sun.scenario.scenegraph.JSGPanel$MouseInputDispatcher.deliver(JSGPanel.java:222)
>>
>> at
>> com.sun.scenario.scenegraph.JSGPanel$MouseInputDispatcher.mouseClicked(JSGPanel.java:352)
>>
>> at
>> com.sun.scenario.scenegraph.JSGPanel$MouseInputDispatcher.mouseClicked(JSGPanel.java:349)
>>
>> at
>> java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
>> at
>> java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
>> at
>> java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:252)
>> at java.awt.Component.processMouseEvent(Component.java:6041)
>> at
>> javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
>> at java.awt.Component.processEvent(Component.java:5803)
>> at java.awt.Container.processEvent(Container.java:2058)
>> at java.awt.Component.dispatchEventImpl(Component.java:4410)
>> at java.awt.Container.dispatchEventImpl(Container.java:2116)
>> at java.awt.Component.dispatchEvent(Component.java:4240)
>> at
>> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
>> at
>> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995)
>> at
>> java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
>> at java.awt.Container.dispatchEventImpl(Container.java:2102)
>> at java.awt.Window.dispatchEventImpl(Window.java:2429)
>> at java.awt.Component.dispatchEvent(Component.java:4240)
>> at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
>> at
>> com.sun.scenario.scenegraph.SGEventQueue.dispatchEvent(SGEventQueue.java:374)
>>
>> at
>> java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
>>
>> at
>> java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
>>
>> at
>> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
>>
>> at
>> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
>> at
>> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
>> at
>> java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@openjfx-compiler.dev.java.net
> For additional commands, e-mail: dev-help@openjfx-compiler.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@scenegraph.dev.java.net
For additional commands, e-mail: dev-help@scenegraph.dev.java.net