[] Problème sur un tuto de : Ser vice/interface

Florent THOMAS <[email protected]> Tue, 19 Jan 2010 23:48:19 +0100
Newsgroups gmane.comp.java.netbeans.general.french
Message-ID <1263941299.21818.6.camel@Dell_Inspiron>
--=-ICxDXfPOSTogpf1TIJxY
Content-Type: text/plain; charset="ISO-8859-15"
Content-Transfer-Encoding: quoted-printable

Bonjour =E0 tous,

J'ai test=E9 le toto suivant :
http://platform.netbeans.org/tutorials/nbm-quick-start.html

Pas de probl=E8mes pour la premi=E8re partie.
En revanche lors de l'utilisation du lookup, j'ai l'anomalie suivante :
java.lang.InstantiationException: org.demo.textfilter.TextFilter
	at java.lang.Class.newInstance0(Class.java:340)
	at java.lang.Class.newInstance(Class.java:308)
	at org.openide.util.lookup.MetaInfServicesLookup
$P.createInstance(MetaInfServicesLookup.java:570)
	at org.openide.util.lookup.MetaInfServicesLookup
$P.getInstance(MetaInfServicesLookup.java:464)
	at
org.openide.util.lookup.AbstractLookup.lookup(AbstractLookup.java:413)
	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:205)
	at
org.demo.wordengine.TextTopComponent.jButton1ActionPerformed(TextTopCompone=
nt.java:86)
	at org.demo.wordengine.TextTopComponent.access
$000(TextTopComponent.java:21)
	at org.demo.wordengine.TextTopComponent
$1.actionPerformed(TextTopComponent.java:51)
	at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
	at javax.swing.AbstractButton
$Handler.actionPerformed(AbstractButton.java:2318)
	at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:=
387)
	at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
	at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListene=
r.java:236)
	at java.awt.Component.processMouseEvent(Component.java:6263)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
	at java.awt.Component.processEvent(Component.java:6028)
	at java.awt.Container.processEvent(Container.java:2041)
	at java.awt.Component.dispatchEventImpl(Component.java:4630)
	at java.awt.Container.dispatchEventImpl(Container.java:2099)
	at java.awt.Component.dispatchEvent(Component.java:4460)
	at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
	at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
	at java.awt.Container.dispatchEventImpl(Container.java:2085)
	at java.awt.Window.dispatchEventImpl(Window.java:2475)
	at java.awt.Component.dispatchEvent(Component.java:4460)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at
org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:12=
5)
	at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.jav=
a:269)
	at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:1=
84)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.jav=
a:174)
	at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
	at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


Dans mon code :

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{                                        =20
        String s =3D jTextArea1.getText();
        TextFilter filter =3D
Lookup.getDefault().lookup(TextFilter.class);
        if (filter !=3D null) {
            s =3D filter.process(s);
            jTextArea1.setText(
    }  =20
}
la variable filter est toujours =E0 null.
J'ai mis toutes les d=E9pendances avec Lookup mais cela ne passe pas.
J'ai bien d=E9clar=E9 l'interface TextFilter comme un service

L=E0 je s=E8che.

Merci de vos conseils =E9clair=E9s

--=-ICxDXfPOSTogpf1TIJxY
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.24.5">
</HEAD>
<BODY>
Bonjour &#224; tous,<BR>
<BR>
J'ai test&#233; le toto suivant :<BR>
<A HREF="http://platform.netbeans.org/tutorials/nbm-quick-start.html">http://platform.netbeans.org/tutorials/nbm-quick-start.html</A><BR>
<BR>
Pas de probl&#232;mes pour la premi&#232;re partie.<BR>
En revanche lors de l'utilisation du lookup, j'ai l'anomalie suivante :<BR>
<I><FONT SIZE="2">java.lang.InstantiationException: org.demo.textfilter.TextFilter</FONT></I><BR>
<I><FONT SIZE="2">	at java.lang.Class.newInstance0(Class.java:340)</FONT></I><BR>
<I><FONT SIZE="2">	at java.lang.Class.newInstance(Class.java:308)</FONT></I><BR>
<I><FONT SIZE="2">	at org.openide.util.lookup.MetaInfServicesLookup$P.createInstance(MetaInfServicesLookup.java:570)</FONT></I><BR>
<I><FONT SIZE="2">	at org.openide.util.lookup.MetaInfServicesLookup$P.getInstance(MetaInfServicesLookup.java:464)</FONT></I><BR>
<I><FONT SIZE="2">	at org.openide.util.lookup.AbstractLookup.lookup(AbstractLookup.java:413)</FONT></I><BR>
<I><FONT SIZE="2">	at org.openide.util.lookup.ProxyLookup.lookup(ProxyLookup.java:205)</FONT></I><BR>
<I><FONT SIZE="2">	at org.demo.wordengine.TextTopComponent.jButton1ActionPerformed(TextTopComponent.java:86)</FONT></I><BR>
<I><FONT SIZE="2">	at org.demo.wordengine.TextTopComponent.access$000(TextTopComponent.java:21)</FONT></I><BR>
<I><FONT SIZE="2">	at org.demo.wordengine.TextTopComponent$1.actionPerformed(TextTopComponent.java:51)</FONT></I><BR>
<I><FONT SIZE="2">	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)</FONT></I><BR>
<I><FONT SIZE="2">	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)</FONT></I><BR>
<I><FONT SIZE="2">	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)</FONT></I><BR>
<I><FONT SIZE="2">	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)</FONT></I><BR>
<I><FONT SIZE="2">	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Component.processMouseEvent(Component.java:6263)</FONT></I><BR>
<I><FONT SIZE="2">	at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Component.processEvent(Component.java:6028)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Container.processEvent(Container.java:2041)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Component.dispatchEventImpl(Component.java:4630)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Container.dispatchEventImpl(Container.java:2099)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Component.dispatchEvent(Component.java:4460)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Container.dispatchEventImpl(Container.java:2085)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Window.dispatchEventImpl(Window.java:2475)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.Component.dispatchEvent(Component.java:4460)</FONT></I><BR>
<I><FONT SIZE="2">[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)</FONT></I><BR>
<I><FONT SIZE="2">	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:125)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)</FONT></I><BR>
<I><FONT SIZE="2">	at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)</FONT></I><BR>
<BR>
<BR>
Dans mon code :<BR>
<BR>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String s = jTextArea1.getText();<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TextFilter filter = Lookup.getDefault().lookup(TextFilter.class);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (filter != null) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s = filter.process(s);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; jTextArea1.setText(<BR>
&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp; <BR>
}<BR>
la variable filter est toujours &#224; null.<BR>
J'ai mis toutes les d&#233;pendances avec Lookup mais cela ne passe pas.<BR>
J'ai bien d&#233;clar&#233; l'interface TextFilter comme un service<BR>
<BR>
L&#224; je s&#232;che.<BR>
<BR>
Merci de vos conseils &#233;clair&#233;s
</BODY>
</HTML>

--=-ICxDXfPOSTogpf1TIJxY--