Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » IllegalArgumentException for own Listener class
IllegalArgumentException for own Listener class [message #459949] Sat, 20 August 2005 19:33 Go to next message
Eclipse UserFriend
Originally posted by: murley.murley.murley

I have a combo box in my application. If i add listener like this, it works
fine:
Combo c = new xxxxx;
c.addListener(SWT.Selection, new Listener(){
public void handleEvent(Event evt){
System.out.println("selection ...");
}
});

I create my own class "MyListener":
public class MyListener implements Listener{
public void handleEvent(Event event){
System.out.println("MyListener ..");
}
}
then if i add listener like this:
MyListener myLis;
c.addListener(SWT.Selection, myLis);

Then java.lang.IllegalArgumentException occur.
Do anyone know what mistake i make?
I have no idea in it...
Thanks
Re: IllegalArgumentException for own Listener class [message #459957 is a reply to message #459949] Sun, 21 August 2005 17:16 Go to previous messageGo to next message
Johan Tibell is currently offline Johan TibellFriend
Messages: 14
Registered: July 2009
Junior Member
murley wrote:
> I have a combo box in my application. If i add listener like this, it works
> fine:
> Combo c = new xxxxx;
> c.addListener(SWT.Selection, new Listener(){
> public void handleEvent(Event evt){
> System.out.println("selection ...");
> }
> });
>
> I create my own class "MyListener":
> public class MyListener implements Listener{
> public void handleEvent(Event event){
> System.out.println("MyListener ..");
> }
> }
> then if i add listener like this:
> MyListener myLis;
> c.addListener(SWT.Selection, myLis);
>
> Then java.lang.IllegalArgumentException occur.
> Do anyone know what mistake i make?
> I have no idea in it...
> Thanks
>
>

Are you sure you wrote:

MyListener myLis;

and not

MyListener myLis = new MyListener();

cause then you probably have a null pointer exception.

- Johan
Re: IllegalArgumentException for own Listener class [message #459958 is a reply to message #459957] Sun, 21 August 2005 17:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: murley.murley.murley

Oh, i forgot to instantiate ...
B.T.W why the error is "IllegalArgumentException" but not
"NullPointerException"
Re: IllegalArgumentException for own Listener class [message #460076 is a reply to message #459958] Mon, 22 August 2005 04:44 Go to previous messageGo to next message
Johan Tibell is currently offline Johan TibellFriend
Messages: 14
Registered: July 2009
Junior Member
murley wrote:
> Oh, i forgot to instantiate ...
> B.T.W why the error is "IllegalArgumentException" but not
> "NullPointerException"
>
>

Because the method checks it's arguments instead of letting the null
pointer be dereferenced:

if (arg == null)
throw new ...
Re: IllegalArgumentException for own Listener class [message #460086 is a reply to message #460076] Mon, 22 August 2005 10:38 Go to previous message
Eclipse UserFriend
Originally posted by: murley.murley.murley

i got it, thanks for reply~
Previous Topic:RSWT?
Next Topic:First ToolItem has raised border in SWT standalone app
Goto Forum:
  


Current Time: Fri Apr 19 01:41:21 GMT 2024

Powered by FUDForum. Page generated in 0.02254 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top