Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Unselecting item on selecting (Read 2892 times)
koosala
Full Member
***
Offline


Java Happens

Posts: 136
Joined: May 13th, 2007
Unselecting item on selecting
Jun 1st, 2007 at 3:47am
Print Post  
Hi,

I wrote the follwing piece of code where I handled the flowchart event itemSelected:

public void itemSelected(ItemEvent ie) {
    ie.getItem().setSelected(false);
}

It had some other code also and some conditions, but I have filtered out the code that caused the problem.

The above line throws an exception:

Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at com.mindfusion.jdiagram.Selection.removeItem(Unknown Source)
at com.mindfusion.jdiagram.Item.setSelected(Unknown Source)
at app.SAApplet$31.itemSelected(SAApplet.java:782)

I am guessing this is a bug, yes?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Unselecting item on selecting
Reply #1 - Jun 1st, 2007 at 6:32am
Print Post  
Hi,

The event is raised before the item is added to a collection, from which setSelected(false) attempts to remove it. I guess we can rearrange a bit the statements in the selection method to make that kind of code work. We will also add an itemSelecting validation event as you suggested in another post.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Unselecting item on selecting
Reply #2 - Jun 4th, 2007 at 12:40pm
Print Post  
This version adds an itemSelecting validation event, and should let you deselect items from the Selected event as well.

http://mindfusion.org/_temp/JDiagram.jar

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint