Java in Visual Studio

A few years ago when I took Java, the class was using Eclipse for the IDE. I came to hate Eclipse with a passion because it kept having errors and would stop running. If I hadn’t saved, I’d have to start the class project over again and that is always annoying.

A few others in the class had the same issue but not everyone. So something about our computers was causing it to not work correctly. While others had no issues whatsoever. Despite knowing this, I still came to hate Eclipse and lamented the fact Visual Studio didn’t have support for Java because its the best IDE around.

I came across an Extension a few months ago though that plans to add Java support to Visual Studio. Its called IntegraStudio. Its presently in beta so you never know how things will turn out. But it looks promising. I wish it was a few years ago when I was taking Java though. Because I bet it will be far better than Eclipse.

Listeners and .Net

I think the instructions for using Listeners or events in the .Net make it sound more complicated than it is. I was reading some text on them when I was working on the spellchecker inside Help Writer to refresh my mind since I don’t use them often. And they just made it more confusing than I remember in class.

I think its far simpler to think of it like this. Inside your control, you need to create an event and a delegate:

public delegate void ReplaceActionDone(string oldtext, string newtext);
public event ReplaceActionDone Replace;

Now the delegate should have the same parameters as the methods that your going to attach to the event in the code outside the control.

In the control’s code you’re going to need to invoke the event where it should perform the necessary code:

Replace?.Invoke(variables.MispelledWord, variables.AcceptedChange);

Now in the parent’s code, you need to set up the methods:

public void ReplaceEvent(string oldText, string newtext)
{

// code to be done

}

And then you need to add it to the control’s event so it fires:

scdialog.Replace += ReplaceEvent;

 

And that’s all there really is to getting an event listener in net.