Create a class....

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Create a class....

Sébastien PETIT
Hello there...

I'm sorry for my English, but I'm French and I'm not sure on how to
explain myself clearly...
But I'll try...

I use indirectly Beanshell because I use Taverna, which is a tool for
Biological data...
But the problem remains intact...I want to create my own
ListSelectionModel for a JList.
So, I thought to create a new class....
But I had problems when I run my script because of this class...

So my question is : can I create a new class and instanciate it in
Beanshell???

Thank you

Sebastien


       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a class....

J. David Boyd-2
Sébastien PETIT <[hidden email]> writes:

> Hello there...
>
> I'm sorry for my English, but I'm French and I'm not sure on how to
> explain myself clearly...
> But I'll try...
>
> I use indirectly Beanshell because I use Taverna, which is a tool for
> Biological data...
> But the problem remains intact...I want to create my own
> ListSelectionModel for a JList.
> So, I thought to create a new class....
> But I had problems when I run my script because of this class...
>
> So my question is : can I create a new class and instanciate it in
> Beanshell???
>
> Thank you
>
> Sebastien

You're english is fine...

I would think that this topic is covered in the documentation for Beanshell.

That is where I would first look...

Dave in Largo, FL



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a class....

brewer
In reply to this post by Sébastien PETIT
Yes, you can create your own Java class and use it in BeanShell.

What was the specific problem you encountered in your script?

A wild guess, but if you are getting a NoClassDefFoundError, you
probably need to tell BeanShell where to find your class. BeanShell
needs 2 things for that: a classpath and a package import (assuming you
put your new class in a package). Is that the problem?

-Philip Lindsey

Sébastien PETIT wrote:

> Hello there...
>
> I'm sorry for my English, but I'm French and I'm not sure on how to
> explain myself clearly...
> But I'll try...
>
> I use indirectly Beanshell because I use Taverna, which is a tool for
> Biological data...
> But the problem remains intact...I want to create my own
> ListSelectionModel for a JList.
> So, I thought to create a new class....
> But I had problems when I run my script because of this class...
>
> So my question is : can I create a new class and instanciate it in
> Beanshell???
>
> Thank you
>
> Sebastien
>
>
>
>
>
>
> ___________________________________________________________________________
> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> Téléchargez cette version sur http://fr.messenger.yahoo.com
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
> July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
> core and dual graphics technology at this free one hour event hosted by HP,
> AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>
>



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a class....

Alexey Zinger
Another thing I'd ask is are you trying to define a class dynamically within
the script or are you trying to load a class from some external library?  If
you're in fact trying to define a new class, like if you wanna implement an
interface within the script, there's a whole section on that here:
http://www.beanshell.org/manual/interfaces.html#Scripting_Interfaces  And of
course, check other sections in the docs and the Wiki.

--- brewer <[hidden email]> wrote:

> Yes, you can create your own Java class and use it in BeanShell.
>
> What was the specific problem you encountered in your script?
>
> A wild guess, but if you are getting a NoClassDefFoundError, you
> probably need to tell BeanShell where to find your class. BeanShell
> needs 2 things for that: a classpath and a package import (assuming you
> put your new class in a package). Is that the problem?
>
> -Philip Lindsey
>
> Sébastien PETIT wrote:
> > Hello there...
> >
> > I'm sorry for my English, but I'm French and I'm not sure on how to
> > explain myself clearly...
> > But I'll try...
> >
> > I use indirectly Beanshell because I use Taverna, which is a tool for
> > Biological data...
> > But the problem remains intact...I want to create my own
> > ListSelectionModel for a JList.
> > So, I thought to create a new class....
> > But I had problems when I run my script because of this class...
> >
> > So my question is : can I create a new class and instanciate it in
> > Beanshell???
> >
> > Thank you
> >
> > Sebastien
> >
> >
> >
> >
> >
> >
> > ___________________________________________________________________________
>
> > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> > Téléchargez cette version sur http://fr.messenger.yahoo.com
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by the 'Do More With Dual!' webinar
> happening
> > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
> > core and dual graphics technology at this free one hour event hosted by HP,
>
> > AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
> > _______________________________________________
> > Beanshell-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/beanshell-users
> >
> >
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
> July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
> core and dual graphics technology at this free one hour event hosted by HP,
> AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>


Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://bsheet.sourceforge.net

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a class....

Sébastien PETIT
Hello,

Yes, I try to define my class within the script...
With the URL you gave me, I tried to script an Interface....
In fact I tried to make a SelectionModel for my Jlist with the
ListSelectionModel Interface...
But I miss something and I don't really understand what...

I wrote that :

########
JList BlastList = new JList();

BlastList.setSelectionModel(new ListSelectionModel(){

    setSelectionInterval(int index0, int index1) {
        if (isSelectedIndex(index0)) {
            DefaultListSelectionModel.removeSelectionInterval(index0,index1);
        }
        else {
            DefaultListSelectionModel.setSelectionInterval(index0,index1);
        }
    }
}
);
########

and I have this answer (I use "bsh-2.0b1.jar" because it is the bsh in
Taverna) :

########
Script threw exception: Sourced file:
C:\...\Essai_BlastParser2_bsh-bis.java : Method Invocation
BlastList.setSelectionModel : at Li
ne: 144 : in file: C:\...\Essai_BlastParser2_bsh-bis.java : BlastList
.setSelectionModel ( new ListSelectionModel ( ) {

Target exception: java.lang.reflect.UndeclaredThrowableException
Nested: Method
addListSelectionListener(javax.swing.plaf.basic.BasicListUI$ListSelectionHandler
) not found in bsh scripted object: AnonymousBlock : at Line: -1 : in
file: <Called from Java Code> : <Compiled Java Code>

java.lang.reflect.UndeclaredThrowableException
        at $Proxy0.addListSelectionListener(Unknown Source)
        at
javax.swing.plaf.basic.BasicListUI$PropertyChangeHandler.propertyChange(BasicListUI.java:1659)
        at
javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:264)
        at
javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:232)
        at
javax.swing.JComponent.firePropertyChange(JComponent.java:3819)
        at javax.swing.JList.setSelectionModel(JList.java:1426)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at bsh.Reflect.invokeOnMethod(Unknown Source)
        at bsh.Reflect.invokeObjectMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at bsh.Interpreter.source(Unknown Source)
        at bsh.Interpreter.main(Unknown Source)
Caused by: Method addListSelectionListener(
javax.swing.plaf.basic.BasicListUI$ListSelectionHandler
) not found in bsh scripted object: AnonymousBlock : at Line: -1 : in
file: <Called from Java Code> : <Compiled Java Code>

        at bsh.This.invokeMethod(Unknown Source)
        at bsh.This.invokeMethod(Unknown Source)
        at bsh.XThis$Handler.invokeImpl(Unknown Source)
        at bsh.XThis$Handler.invoke(Unknown Source)
        ... 19 more
########

So, must I implement all the interface with the
DefaultListSelectionModel class or is there another solution...???
(and I want to try to leave the code within the script..)

Thank you....

Sebastien

--- Alexey Zinger <[hidden email]> a écrit :

> Another thing I'd ask is are you trying to define a class dynamically
> within
> the script or are you trying to load a class from some external
> library?  If
> you're in fact trying to define a new class, like if you wanna
> implement an
> interface within the script, there's a whole section on that here:
> http://www.beanshell.org/manual/interfaces.html#Scripting_Interfaces 
> And of
> course, check other sections in the docs and the Wiki.
>
> --- brewer <[hidden email]> wrote:
>
> > Yes, you can create your own Java class and use it in BeanShell.
> >
> > What was the specific problem you encountered in your script?
> >
> > A wild guess, but if you are getting a NoClassDefFoundError, you
> > probably need to tell BeanShell where to find your class. BeanShell
>
> > needs 2 things for that: a classpath and a package import (assuming
> you
> > put your new class in a package). Is that the problem?
> >
> > -Philip Lindsey
> >
> > Sébastien PETIT wrote:
> > > Hello there...
> > >
> > > I'm sorry for my English, but I'm French and I'm not sure on how
> to
> > > explain myself clearly...
> > > But I'll try...
> > >
> > > I use indirectly Beanshell because I use Taverna, which is a tool
> for
> > > Biological data...
> > > But the problem remains intact...I want to create my own
> > > ListSelectionModel for a JList.
> > > So, I thought to create a new class....
> > > But I had problems when I run my script because of this class...
> > >
> > > So my question is : can I create a new class and instanciate it
> in
> > > Beanshell???
> > >
> > > Thank you
> > >
> > > Sebastien
> > >
> > >
> > >
> > >
> > >
> > >
> > >
>
___________________________________________________________________________

> >
> > > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo!
> Messenger
> > > Téléchargez cette version sur http://fr.messenger.yahoo.com
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by the 'Do More With Dual!'
> webinar
> > happening
> > > July 14 at 8am PDT/11am EDT. We invite you to explore the latest
> in dual
> > > core and dual graphics technology at this free one hour event
> hosted by HP,
> >
> > > AMD, and NVIDIA.  To register visit
> http://www.hp.com/go/dualwebinar
> > > _______________________________________________
> > > Beanshell-users mailing list
> > > [hidden email]
> > > https://lists.sourceforge.net/lists/listinfo/beanshell-users
> > >
> > >
> >
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by the 'Do More With Dual!' webinar
> happening
> > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in
> dual
> > core and dual graphics technology at this free one hour event
> hosted by HP,
> > AMD, and NVIDIA.  To register visit
> http://www.hp.com/go/dualwebinar
> > _______________________________________________
> > Beanshell-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/beanshell-users
> >
>
>
> Alexey
> 2001 Honda CBR600F4i (CCS)
> 1992 Kawasaki EX500
> http://bsheet.sourceforge.net
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com 
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the 'Do More With Dual!' webinar
> happening
> July 14 at 8am PDT/11am EDT. We invite you to explore the latest in
> dual
> core and dual graphics technology at this free one hour event hosted
> by HP,
> AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>



       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a class....

Alexey Zinger
You're not implementing all the methods of ListSelectionModel:

public abstract int getAnchorSelectionIndex();
public abstract int getLeadSelectionIndex();
public abstract int getMaxSelectionIndex();
public abstract int getMinSelectionIndex();
public abstract int getSelectionMode();
public abstract void clearSelection();
public abstract boolean getValueIsAdjusting();
public abstract boolean isSelectionEmpty();
public abstract void setAnchorSelectionIndex(int);
public abstract void setLeadSelectionIndex(int);
public abstract void setSelectionMode(int);
public abstract boolean isSelectedIndex(int);
public abstract void addSelectionInterval(int,int);
public abstract void removeIndexInterval(int,int);
public abstract void removeSelectionInterval(int,int);
public abstract void setSelectionInterval(int,int);
public abstract void insertIndexInterval(int,int,boolean);
public abstract void setValueIsAdjusting(boolean);
public abstract void
addListSelectionListener(javax.swing.event.ListSelectionListener);
public abstract void
removeListSelectionListener(javax.swing.event.ListSelectionListener);

This is a lot to stick in your scripted object when all you wanna implement is
one method beyond default functionality.  You're only implementing one method:
setSelectionInterval(int, int).  Take a look at what the docs say about
incomplete interface implementations in BeanShell:

""Dummy" Adapters and Incomplete Interfaces
It is common in Java to see "dummy" adapters created for interfaces that have
more than one method. The job of a dummy adapter is to implement all of the
methods of the interface with stubs (empty bodies), allowing the developer to
extend the adapter and override just the methods of interest.

We hinted in our earlier discussion that BeanShell could handle scripted
interfaces that implement only the subset of methods that are actually used and
that is indeed the case. You are free in BeanShell to script only the interface
methods that you expect to be called. The penalty for leaving out a method that
is actually invoked is a special run-time exception:
java.lang.reflect.UndeclaredThrowableException, which the caller will receive.

The UndeclaredThrowableException is an artifact of Java Proxy API that makes
dynamic interfaces possible. It says that an interface threw a checked
exception type that was not prescribed by the method signature. This is a
situation that cannot normally happen in compiled Java. So the Java reflection
API handles it by wrapping the checked exception in this special unchecked
(RuntimeException) type in order to throw it. You can get the underlying error
using the exception's getCause() method, which will, in this case, reveal the
BeanShell EvalError exception, reporting that the scripted method of the
correct signature was not found. "

Looking at your stacktrace and the cause of UndeclaredThrowableException, your
object is missing a method that's being called: addListSelectionListener.  You
have a couple of options:

1. implement the method and continue testing until your object impelments every
method that's being called on it; or

2. do an anonymous subclass of DefaultListSelectionModel and only override the
methods you want.

I have never tried 2, but I just did this and it didn't throw any nasty
exceptions, though I can't say it's actually doing the right thing, that's up
to you to test:

impl = new DefaultSelectionModel()
{
   setSelectionInterval(start, end) {}
};

--- Sébastien PETIT <[hidden email]> wrote:

> Hello,
>
> Yes, I try to define my class within the script...
> With the URL you gave me, I tried to script an Interface....
> In fact I tried to make a SelectionModel for my Jlist with the
> ListSelectionModel Interface...
> But I miss something and I don't really understand what...
>
> I wrote that :
>
> ########
> JList BlastList = new JList();
>
> BlastList.setSelectionModel(new ListSelectionModel(){
>
>     setSelectionInterval(int index0, int index1) {
> if (isSelectedIndex(index0)) {
>    DefaultListSelectionModel.removeSelectionInterval(index0,index1);
> }
> else {
>    DefaultListSelectionModel.setSelectionInterval(index0,index1);
> }
>     }
> }
> );
> ########
>
> and I have this answer (I use "bsh-2.0b1.jar" because it is the bsh in
> Taverna) :
>
> ########
> Script threw exception: Sourced file:
> C:\...\Essai_BlastParser2_bsh-bis.java : Method Invocation
> BlastList.setSelectionModel : at Li
> ne: 144 : in file: C:\...\Essai_BlastParser2_bsh-bis.java : BlastList
> .setSelectionModel ( new ListSelectionModel ( ) {
>
> Target exception: java.lang.reflect.UndeclaredThrowableException
> Nested: Method
>
addListSelectionListener(javax.swing.plaf.basic.BasicListUI$ListSelectionHandler
> ) not found in bsh scripted object: AnonymousBlock : at Line: -1 : in
> file: <Called from Java Code> : <Compiled Java Code>
>
> java.lang.reflect.UndeclaredThrowableException
>         at $Proxy0.addListSelectionListener(Unknown Source)
>         at
>
javax.swing.plaf.basic.BasicListUI$PropertyChangeHandler.propertyChange(BasicListUI.java:1659)
>         at
>
javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:264)
>         at
>
javax.swing.event.SwingPropertyChangeSupport.firePropertyChange(SwingPropertyChangeSupport.java:232)
>         at
> javax.swing.JComponent.firePropertyChange(JComponent.java:3819)
>         at javax.swing.JList.setSelectionModel(JList.java:1426)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

>         at java.lang.reflect.Method.invoke(Method.java:324)
>         at bsh.Reflect.invokeOnMethod(Unknown Source)
>         at bsh.Reflect.invokeObjectMethod(Unknown Source)
>         at bsh.Name.invokeMethod(Unknown Source)
>         at bsh.BSHMethodInvocation.eval(Unknown Source)
>         at bsh.BSHPrimaryExpression.eval(Unknown Source)
>         at bsh.BSHPrimaryExpression.eval(Unknown Source)
>         at bsh.Interpreter.eval(Unknown Source)
>         at bsh.Interpreter.source(Unknown Source)
>         at bsh.Interpreter.main(Unknown Source)
> Caused by: Method addListSelectionListener(
> javax.swing.plaf.basic.BasicListUI$ListSelectionHandler
> ) not found in bsh scripted object: AnonymousBlock : at Line: -1 : in
> file: <Called from Java Code> : <Compiled Java Code>
>
>         at bsh.This.invokeMethod(Unknown Source)
>         at bsh.This.invokeMethod(Unknown Source)
>         at bsh.XThis$Handler.invokeImpl(Unknown Source)
>         at bsh.XThis$Handler.invoke(Unknown Source)
>         ... 19 more
> ########
>
> So, must I implement all the interface with the
> DefaultListSelectionModel class or is there another solution...???
> (and I want to try to leave the code within the script..)
>
> Thank you....
>
> Sebastien
>
> --- Alexey Zinger <[hidden email]> a écrit :
>
> > Another thing I'd ask is are you trying to define a class dynamically
> > within
> > the script or are you trying to load a class from some external
> > library?  If
> > you're in fact trying to define a new class, like if you wanna
> > implement an
> > interface within the script, there's a whole section on that here:
> > http://www.beanshell.org/manual/interfaces.html#Scripting_Interfaces 
> > And of
> > course, check other sections in the docs and the Wiki.
> >
> > --- brewer <[hidden email]> wrote:
> >
> > > Yes, you can create your own Java class and use it in BeanShell.
> > >
> > > What was the specific problem you encountered in your script?
> > >
> > > A wild guess, but if you are getting a NoClassDefFoundError, you
> > > probably need to tell BeanShell where to find your class. BeanShell
> >
> > > needs 2 things for that: a classpath and a package import (assuming
> > you
> > > put your new class in a package). Is that the problem?
> > >
> > > -Philip Lindsey
> > >
> > > Sébastien PETIT wrote:
> > > > Hello there...
> > > >
> > > > I'm sorry for my English, but I'm French and I'm not sure on how
> > to
> > > > explain myself clearly...
> > > > But I'll try...
> > > >
> > > > I use indirectly Beanshell because I use Taverna, which is a tool
> > for
> > > > Biological data...
> > > > But the problem remains intact...I want to create my own
> > > > ListSelectionModel for a JList.
> > > > So, I thought to create a new class....
> > > > But I had problems when I run my script because of this class...
> > > >
> > > > So my question is : can I create a new class and instanciate it
> > in
> > > > Beanshell???
> > > >
> > > > Thank you
> > > >
> > > > Sebastien
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> >
> ___________________________________________________________________________
> > >
> > > > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo!
> > Messenger
> > > > Téléchargez cette version sur http://fr.messenger.yahoo.com
> > > >
> > > >
> > > > -------------------------------------------------------
> > > > This SF.Net email is sponsored by the 'Do More With Dual!'
> > webinar
> > > happening
> > > > July 14 at 8am PDT/11am EDT. We invite you to explore the latest
> > in dual
> > > > core and dual graphics technology at this free one hour event
> > hosted by HP,
> > >
> > > > AMD, and NVIDIA.  To register visit
> > http://www.hp.com/go/dualwebinar
> > > > _______________________________________________
> > > > Beanshell-users mailing list
> > > > [hidden email]
> > > > https://lists.sourceforge.net/lists/listinfo/beanshell-users
> > > >
> > > >
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This SF.Net email is sponsored by the 'Do More With Dual!' webinar
> > happening
> > > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in
> > dual
> > > core and dual graphics technology at this free one hour event
> > hosted by HP,
> > > AMD, and NVIDIA.  To register visit
> > http://www.hp.com/go/dualwebinar
> > > _______________________________________________
> > > Beanshell-users mailing list
> > > [hidden email]
> > > https://lists.sourceforge.net/lists/listinfo/beanshell-users
> > >
> >
> >
> > Alexey
> > 2001 Honda CBR600F4i (CCS)
> > 1992 Kawasaki EX500
> > http://bsheet.sourceforge.net
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com 
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by the 'Do More With Dual!' webinar
> > happening
> > July 14 at 8am PDT/11am EDT. We invite you to explore the latest in
> > dual
> > core and dual graphics technology at this free one hour event hosted
> > by HP,
> > AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
> > _______________________________________________
> > Beanshell-users mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/beanshell-users
> >
>
>
>
>
>
>
>
> ___________________________________________________________________________
> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> Téléchargez cette version sur http://fr.messenger.yahoo.com
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
> July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
> core and dual graphics technology at this free one hour event hosted by HP,
> AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users
>


Alexey
2001 Honda CBR600F4i (CCS)
1992 Kawasaki EX500
http://bsheet.sourceforge.net

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com 


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Create a class....

Sébastien PETIT
Yes, I saw I didn't implement all the methods....
I did today with a copy-&-past from the DefaultListSelectionModel...
It's boring...;);)...
So, I did you're first solution...

The 2nd one is not working....In fact, it didn't go in my overrided
method...

I put some "System.out.println" in it, and I saw nothing...
There is what I wrote with the 2nd solution :
#######
impl = new DefaultListSelectionModel()
{
    setSelectionInterval(int index0, int index1) {
                if (isSelectedIndex(index0)) {
                        System.out.println("pouet" ) ;
                        removeSelectionInterval( index0,  index1);
                }
                else {
                        System.out.println("tututu" ) ;
                        addSelectionInterval(index0,index1);
                }
    }
};
#######

Maybe I'm wrong....

But the 1st solution works, but it takes a long time...

Sebastien

--- Alexey Zinger <[hidden email]> a écrit :

> You're not implementing all the methods of ListSelectionModel:
>
> public abstract int getAnchorSelectionIndex();
> public abstract int getLeadSelectionIndex();
> public abstract int getMaxSelectionIndex();
> public abstract int getMinSelectionIndex();
> public abstract int getSelectionMode();
> public abstract void clearSelection();
> public abstract boolean getValueIsAdjusting();
> public abstract boolean isSelectionEmpty();
> public abstract void setAnchorSelectionIndex(int);
> public abstract void setLeadSelectionIndex(int);
> public abstract void setSelectionMode(int);
> public abstract boolean isSelectedIndex(int);
> public abstract void addSelectionInterval(int,int);
> public abstract void removeIndexInterval(int,int);
> public abstract void removeSelectionInterval(int,int);
> public abstract void setSelectionInterval(int,int);
> public abstract void insertIndexInterval(int,int,boolean);
> public abstract void setValueIsAdjusting(boolean);
> public abstract void
> addListSelectionListener(javax.swing.event.ListSelectionListener);
> public abstract void
> removeListSelectionListener(javax.swing.event.ListSelectionListener);
>
> This is a lot to stick in your scripted object when all you wanna
> implement is
> one method beyond default functionality.  You're only implementing
> one method:
> setSelectionInterval(int, int).  Take a look at what the docs say
> about
> incomplete interface implementations in BeanShell:
>
> ""Dummy" Adapters and Incomplete Interfaces
> It is common in Java to see "dummy" adapters created for interfaces
> that have
> more than one method. The job of a dummy adapter is to implement all
> of the
> methods of the interface with stubs (empty bodies), allowing the
> developer to
> extend the adapter and override just the methods of interest.
>
> We hinted in our earlier discussion that BeanShell could handle
> scripted
> interfaces that implement only the subset of methods that are
> actually used and
> that is indeed the case. You are free in BeanShell to script only the
> interface
> methods that you expect to be called. The penalty for leaving out a
> method that
> is actually invoked is a special run-time exception:
> java.lang.reflect.UndeclaredThrowableException, which the caller will
> receive.
>
> The UndeclaredThrowableException is an artifact of Java Proxy API
> that makes
> dynamic interfaces possible. It says that an interface threw a
> checked
> exception type that was not prescribed by the method signature. This
> is a
> situation that cannot normally happen in compiled Java. So the Java
> reflection
> API handles it by wrapping the checked exception in this special
> unchecked
> (RuntimeException) type in order to throw it. You can get the
> underlying error
> using the exception's getCause() method, which will, in this case,
> reveal the
> BeanShell EvalError exception, reporting that the scripted method of
> the
> correct signature was not found. "
>
> Looking at your stacktrace and the cause of
> UndeclaredThrowableException, your
> object is missing a method that's being called:
> addListSelectionListener.  You
> have a couple of options:
>
> 1. implement the method and continue testing until your object
> impelments every
> method that's being called on it; or
>
> 2. do an anonymous subclass of DefaultListSelectionModel and only
> override the
> methods you want.
>
> I have never tried 2, but I just did this and it didn't throw any
> nasty
> exceptions, though I can't say it's actually doing the right thing,
> that's up
> to you to test:
>
> impl = new DefaultSelectionModel()
> {
>    setSelectionInterval(start, end) {}
> };



       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

RE: Create a class....

Daniel Leuck
Hi Sebastien,

Your second solution is the better approach.  Use the full method signature
like so:

--------------------
impl = new DefaultListSelectionModel()
{
     public void setSelectionInterval(int index0, int index1) {
  if (isSelectedIndex(index0)) {
  print("pouet" ) ;
  removeSelectionInterval( index0,  index1);
  }
  else {
  print("tututu") ;
  addSelectionInterval(index0,index1);
  }
     }
};

list = new JList(new String[] {"one","two","three"});
list.setSelectionModel(impl);
frame(list);
--------------------

And it will work fine.

Cheers,
Dan

> -----Original Message-----
> From: [hidden email] [mailto:beanshell-users-
> [hidden email]] On Behalf Of Sébastien PETIT
> Sent: Wednesday, July 13, 2005 6:47 AM
> To: [hidden email]
> Subject: Re: [Beanshell-users] Create a class....
>
> Yes, I saw I didn't implement all the methods....
> I did today with a copy-&-past from the DefaultListSelectionModel...
> It's boring...;);)...
> So, I did you're first solution...
>
> The 2nd one is not working....In fact, it didn't go in my overrided
> method...
>
> I put some "System.out.println" in it, and I saw nothing...
> There is what I wrote with the 2nd solution :
> #######
> impl = new DefaultListSelectionModel()
> {
>     setSelectionInterval(int index0, int index1) {
> if (isSelectedIndex(index0)) {
> System.out.println("pouet" ) ;
> removeSelectionInterval( index0,  index1);
> }
> else {
> System.out.println("tututu" ) ;
> addSelectionInterval(index0,index1);
> }
>     }
> };
> #######
>
> Maybe I'm wrong....
>
> But the 1st solution works, but it takes a long time...
>
> Sebastien
>
> --- Alexey Zinger <[hidden email]> a écrit :
>
> > You're not implementing all the methods of ListSelectionModel:
> >
> > public abstract int getAnchorSelectionIndex();
> > public abstract int getLeadSelectionIndex();
> > public abstract int getMaxSelectionIndex();
> > public abstract int getMinSelectionIndex();
> > public abstract int getSelectionMode();
> > public abstract void clearSelection();
> > public abstract boolean getValueIsAdjusting();
> > public abstract boolean isSelectionEmpty();
> > public abstract void setAnchorSelectionIndex(int);
> > public abstract void setLeadSelectionIndex(int);
> > public abstract void setSelectionMode(int);
> > public abstract boolean isSelectedIndex(int);
> > public abstract void addSelectionInterval(int,int);
> > public abstract void removeIndexInterval(int,int);
> > public abstract void removeSelectionInterval(int,int);
> > public abstract void setSelectionInterval(int,int);
> > public abstract void insertIndexInterval(int,int,boolean);
> > public abstract void setValueIsAdjusting(boolean);
> > public abstract void
> > addListSelectionListener(javax.swing.event.ListSelectionListener);
> > public abstract void
> > removeListSelectionListener(javax.swing.event.ListSelectionListener);
> >
> > This is a lot to stick in your scripted object when all you wanna
> > implement is
> > one method beyond default functionality.  You're only implementing
> > one method:
> > setSelectionInterval(int, int).  Take a look at what the docs say
> > about
> > incomplete interface implementations in BeanShell:
> >
> > ""Dummy" Adapters and Incomplete Interfaces
> > It is common in Java to see "dummy" adapters created for interfaces
> > that have
> > more than one method. The job of a dummy adapter is to implement all
> > of the
> > methods of the interface with stubs (empty bodies), allowing the
> > developer to
> > extend the adapter and override just the methods of interest.
> >
> > We hinted in our earlier discussion that BeanShell could handle
> > scripted
> > interfaces that implement only the subset of methods that are
> > actually used and
> > that is indeed the case. You are free in BeanShell to script only the
> > interface
> > methods that you expect to be called. The penalty for leaving out a
> > method that
> > is actually invoked is a special run-time exception:
> > java.lang.reflect.UndeclaredThrowableException, which the caller will
> > receive.
> >
> > The UndeclaredThrowableException is an artifact of Java Proxy API
> > that makes
> > dynamic interfaces possible. It says that an interface threw a
> > checked
> > exception type that was not prescribed by the method signature. This
> > is a
> > situation that cannot normally happen in compiled Java. So the Java
> > reflection
> > API handles it by wrapping the checked exception in this special
> > unchecked
> > (RuntimeException) type in order to throw it. You can get the
> > underlying error
> > using the exception's getCause() method, which will, in this case,
> > reveal the
> > BeanShell EvalError exception, reporting that the scripted method of
> > the
> > correct signature was not found. "
> >
> > Looking at your stacktrace and the cause of
> > UndeclaredThrowableException, your
> > object is missing a method that's being called:
> > addListSelectionListener.  You
> > have a couple of options:
> >
> > 1. implement the method and continue testing until your object
> > impelments every
> > method that's being called on it; or
> >
> > 2. do an anonymous subclass of DefaultListSelectionModel and only
> > override the
> > methods you want.
> >
> > I have never tried 2, but I just did this and it didn't throw any
> > nasty
> > exceptions, though I can't say it's actually doing the right thing,
> > that's up
> > to you to test:
> >
> > impl = new DefaultSelectionModel()
> > {
> >    setSelectionInterval(start, end) {}
> > };
>
>
>
>
>
>
>
> __________________________________________________________________________
> _
> Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
> Téléchargez cette version sur http://fr.messenger.yahoo.com
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by the 'Do More With Dual!' webinar
> happening
> July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
> core and dual graphics technology at this free one hour event hosted by
HP,
> AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
> _______________________________________________
> Beanshell-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/beanshell-users



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

RE: <SOLVED>Create a class....

Sébastien PETIT
Thanks a lot....!!!!

I forgot the "public void" in the method signature, that why it didn't
work....!!
And, now it's good..!!
100 lines in less!!

Thank you....

Sebastien

--- Daniel Leuck <[hidden email]> a écrit :

> Hi Sebastien,
>
> Your second solution is the better approach.  Use the full method
> signature
> like so:
>
> --------------------
> impl = new DefaultListSelectionModel()
> {
>      public void setSelectionInterval(int index0, int index1) {
>   if (isSelectedIndex(index0)) {
>   print("pouet" ) ;
>   removeSelectionInterval( index0,  index1);
>   }
>   else {
>   print("tututu") ;
>   addSelectionInterval(index0,index1);
>   }
>      }
> };
>
> list = new JList(new String[] {"one","two","three"});
> list.setSelectionModel(impl);
> frame(list);
> --------------------
>
> And it will work fine.
>
> Cheers,
> Dan
>
> > -----Original Message-----
> > From: [hidden email]
> [mailto:beanshell-users-
> > [hidden email]] On Behalf Of Sébastien PETIT
> > Sent: Wednesday, July 13, 2005 6:47 AM
> > To: [hidden email]
> > Subject: Re: [Beanshell-users] Create a class....
> >
> > Yes, I saw I didn't implement all the methods....
> > I did today with a copy-&-past from the
> DefaultListSelectionModel...
> > It's boring...;);)...
> > So, I did you're first solution...
> >
> > The 2nd one is not working....In fact, it didn't go in my overrided
> > method...
> >
> > I put some "System.out.println" in it, and I saw nothing...
> > There is what I wrote with the 2nd solution :
> > #######
> > impl = new DefaultListSelectionModel()
> > {
> >     setSelectionInterval(int index0, int index1) {
> > if (isSelectedIndex(index0)) {
> > System.out.println("pouet" ) ;
> > removeSelectionInterval( index0,  index1);
> > }
> > else {
> > System.out.println("tututu" ) ;
> > addSelectionInterval(index0,index1);
> > }
> >     }
> > };
> > #######
> >
> > Maybe I'm wrong....
> >
> > But the 1st solution works, but it takes a long time...
> >
> > Sebastien
> >
> > --- Alexey Zinger <[hidden email]> a écrit :
> >
> > > You're not implementing all the methods of ListSelectionModel:
> > >
> > > public abstract int getAnchorSelectionIndex();
> > > public abstract int getLeadSelectionIndex();
> > > public abstract int getMaxSelectionIndex();
> > > public abstract int getMinSelectionIndex();
> > > public abstract int getSelectionMode();
> > > public abstract void clearSelection();
> > > public abstract boolean getValueIsAdjusting();
> > > public abstract boolean isSelectionEmpty();
> > > public abstract void setAnchorSelectionIndex(int);
> > > public abstract void setLeadSelectionIndex(int);
> > > public abstract void setSelectionMode(int);
> > > public abstract boolean isSelectedIndex(int);
> > > public abstract void addSelectionInterval(int,int);
> > > public abstract void removeIndexInterval(int,int);
> > > public abstract void removeSelectionInterval(int,int);
> > > public abstract void setSelectionInterval(int,int);
> > > public abstract void insertIndexInterval(int,int,boolean);
> > > public abstract void setValueIsAdjusting(boolean);
> > > public abstract void
> > >
> addListSelectionListener(javax.swing.event.ListSelectionListener);
> > > public abstract void
> > >
> removeListSelectionListener(javax.swing.event.ListSelectionListener);
> > >
> > > This is a lot to stick in your scripted object when all you wanna
> > > implement is
> > > one method beyond default functionality.  You're only
> implementing
> > > one method:
> > > setSelectionInterval(int, int).  Take a look at what the docs say
> > > about
> > > incomplete interface implementations in BeanShell:
> > >
> > > ""Dummy" Adapters and Incomplete Interfaces
> > > It is common in Java to see "dummy" adapters created for
> interfaces
> > > that have
> > > more than one method. The job of a dummy adapter is to implement
> all
> > > of the
> > > methods of the interface with stubs (empty bodies), allowing the
> > > developer to
> > > extend the adapter and override just the methods of interest.
> > >
> > > We hinted in our earlier discussion that BeanShell could handle
> > > scripted
> > > interfaces that implement only the subset of methods that are
> > > actually used and
> > > that is indeed the case. You are free in BeanShell to script only
> the
> > > interface
> > > methods that you expect to be called. The penalty for leaving out
> a
> > > method that
> > > is actually invoked is a special run-time exception:
> > > java.lang.reflect.UndeclaredThrowableException, which the caller
> will
> > > receive.
> > >
> > > The UndeclaredThrowableException is an artifact of Java Proxy API
> > > that makes
> > > dynamic interfaces possible. It says that an interface threw a
> > > checked
> > > exception type that was not prescribed by the method signature.
> This
> > > is a
> > > situation that cannot normally happen in compiled Java. So the
> Java
> > > reflection
> > > API handles it by wrapping the checked exception in this special
> > > unchecked
> > > (RuntimeException) type in order to throw it. You can get the
> > > underlying error
> > > using the exception's getCause() method, which will, in this
> case,
> > > reveal the
> > > BeanShell EvalError exception, reporting that the scripted method
> of
> > > the
> > > correct signature was not found. "
> > >
> > > Looking at your stacktrace and the cause of
> > > UndeclaredThrowableException, your
> > > object is missing a method that's being called:
> > > addListSelectionListener.  You
> > > have a couple of options:
> > >
> > > 1. implement the method and continue testing until your object
> > > impelments every
> > > method that's being called on it; or
> > >
> > > 2. do an anonymous subclass of DefaultListSelectionModel and only
> > > override the
> > > methods you want.
> > >
> > > I have never tried 2, but I just did this and it didn't throw any
> > > nasty
> > > exceptions, though I can't say it's actually doing the right
> thing,
> > > that's up
> > > to you to test:
> > >
> > > impl = new DefaultSelectionModel()
> > > {
> > >    setSelectionInterval(start, end) {}
> > > };
> >
> >
> >
> >
> >
> >
> >
> >
>
__________________________________________________________________________

> > _
> > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo!
> Messenger
> > Téléchargez cette version sur http://fr.messenger.yahoo.com
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by the 'Do More With Dual!' webinar
> > happening
>
=== message truncated ===



       

       
               
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users