bonjour,
mon code est en java il inclut l'utilisation d'un jSpinner,je travaille avec netbeans,et j'ai modifié les propriétes de model de ce jSpinner en spécifiant son min à 1 et son max à 30,je veut que lorsque j'avance ou je décrémente avec ce jSpinner,il va récupérer la variable d'un jTextField1 saisie et exécute une commande en arriére plan et envoi la réponse dans le jTextarea,or lorsque je compile et j'essaye d'avancer avec ce jSpinner j'aurai un levé d'exeption,et il ne marche plus malgré que j'ai ajouté un addChangeListener :
run:
Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperation Exception: Not supported yet.
at traceroute_swing.window_swing. stateChanged(window_swing.java :451)
at javax.swing.JSpinner.fireState Changed(JSpinner.java:434)
at javax.swing.JSpinner$ModelList ener.stateChanged(JSpinner.jav a:361)
at javax.swing.AbstractSpinnerMod el.fireStateChanged(AbstractSp innerModel.java:102)
at javax.swing.SpinnerNumberModel .setValue(SpinnerNumberModel.j ava:430)
at javax.swing.JSpinner.setValue( JSpinner.java:329)
at javax.swing.plaf.basic.BasicSp innerUI$ArrowButtonHandler.act ionPerformed(BasicSpinnerUI.ja va:643)
at javax.swing.AbstractButton.fir eActionPerformed(AbstractButto n.java:1995)
at javax.swing.AbstractButton$Han dler.actionPerformed(AbstractB utton.java:2318)
at javax.swing.DefaultButtonModel .fireActionPerformed(DefaultBu ttonModel.java:387)
at javax.swing.DefaultButtonModel .setPressed(DefaultButtonModel .java:242)
at javax.swing.plaf.basic.BasicBu ttonListener.mouseReleased(Bas icButtonListener.java:236)
at java.awt.AWTEventMulticaster.m ouseReleased(AWTEventMulticast er.java:272)
at java.awt.Component.processMous eEvent(Component.java:6289)
at javax.swing.JComponent.process MouseEvent(JComponent.java:326 7)
at java.awt.Component.processEven t(Component.java:6054)
at java.awt.Container.processEven t(Container.java:2041)
at java.awt.Component.dispatchEve ntImpl(Component.java:4652)
at java.awt.Container.dispatchEve ntImpl(Container.java:2099)
at java.awt.Component.dispatchEve nt(Component.java:4482)
at java.awt.LightweightDispatcher .retargetMouseEvent(Container. java:4577)
at java.awt.LightweightDispatcher .processMouseEvent(Container.j ava:4238)
at java.awt.LightweightDispatcher .dispatchEvent(Container.java: 4168)
at java.awt.Container.dispatchEve ntImpl(Container.java:2085)
at java.awt.Window.dispatchEventI mpl(Window.java:2478)
at java.awt.Component.dispatchEve nt(Component.java:4482)
at java.awt.EventQueue.dispatchEv entImpl(EventQueue.java:644)
at java.awt.EventQueue.access$000 (EventQueue.java:85)
at java.awt.EventQueue$1.run(Even tQueue.java:603)
at java.awt.EventQueue$1.run(Even tQueue.java:601)
at java.security.AccessController .doPrivileged(Native Method)
at java.security.AccessControlCon text$1.doIntersectionPrivilege (AccessControlContext.java:87)
at java.security.AccessControlCon text$1.doIntersectionPrivilege (AccessControlContext.java:98)
at java.awt.EventQueue$2.run(Even tQueue.java:617)
at java.awt.EventQueue$2.run(Even tQueue.java:615)
at java.security.AccessController .doPrivileged(Native Method)
at java.security.AccessControlCon text$1.doIntersectionPrivilege (AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEv ent(EventQueue.java:614)
at java.awt.EventDispatchThread.p umpOneEventForFilters(EventDis patchThread.java:269)
at java.awt.EventDispatchThread.p umpEventsForFilter(EventDispat chThread.java:184)
at java.awt.EventDispatchThread.p umpEventsForHierarchy(EventDis patchThread.java:174)
at java.awt.EventDispatchThread.p umpEvents(EventDispatchThread. java:169)
at java.awt.EventDispatchThread.p umpEvents(EventDispatchThread. java:161)
at java.awt.EventDispatchThread.r un(EventDispatchThread.java:12 2)
et voici mon méthode changeListner de ce jSpinner:
et merci pour tout aide pour résoudre mon problémeCode:private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) { // TODO add your handling code here: Object sp=jSpinner1.getValue(); int i =Integer.parseInt(sp.toString() ); String target=jTextField1.getText(); try{ jSpinner1StateChanged(evt); String cmd = "tracert -j "+i+ "" +target; Process p = Runtime.getRuntime().exec(cmd); InputStream in = p.getInputStream(); StringBuilder build = new StringBuilder(); Reader reader = new InputStreamReader(in); char[] buffer = new char[512]; int nbRead = reader.read(buffer); while(nbRead > 0) { build.append(buffer, 0, nbRead); nbRead = reader.read(buffer); } String response = build.toString(); jTextArea1.setText(response); }catch(Exception e){ jTextArea1.append(e.toString()); } }
-----