2 Replies - 827 Views - Last Post: 21 February 2012 - 05:34 AM Rate Topic: -----

#1 fatma50   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 11-February 12

problem with my jspinner code

Posted 21 February 2012 - 04:46 AM

hello,
I have a problem with my code with the jSpinner,I work with netbeans, and I changed the properties of the jSpinner model by specifying the min to 1 and the max to 30, I want that when I move or I decreases with the JSpinner, it will grab the variable from jTextField1 and executes a command in the background then sends the answer in the JTextArea,but when I compile and try to increment with it I will have many error of exception, and it will not work even though I have added a addChangeListener:
this is my code:

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()); } 

}


and i is the value that I was get from the jspinner,thanks for any help to resilve my problem

Is This A Good Question/Topic? 0
  • +

Replies To: problem with my jspinner code

#2 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8378
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: problem with my jspinner code

Posted 21 February 2012 - 04:57 AM

which errors ?
Was This Post Helpful? 0
  • +
  • -

#3 fatma50   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 11-February 12

Re: problem with my jspinner code

Posted 21 February 2012 - 05:34 AM

when I try to increment the value of the jSpinner ,I have many exception errors those are the exeption errors concerns the model and the method statechanged of the jSpinner:

Exception in thread "AWT-EventQueue-0" java.lang.UnsupportedOperationException: Not supported yet.
at traceroute_swing.window_swing.stateChanged(window_swing.java:451)
at javax.swing.JSpinner.fireStateChanged(JSpinner.java:434)
at javax.swing.JSpinner$ModelListener.stateChanged(JSpinner.java:361)
at javax.swing.AbstractSpinnerModel.fireStateChanged(AbstractSpinnerModel.java:102)
at javax.swing.SpinnerNumberModel.setValue(SpinnerNumberModel.java:430)
at javax.swing.JSpinner.setValue(JSpinner.java:329)
at javax.swing.JSpinner$DefaultEditor.propertyChange(JSpinner.java:746)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
at java.awt.Component.firePropertyChange(Component.java:8154)
at javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:782)
at javax.swing.JFormattedTextField.commitEdit(JFormattedTextField.java:513)
at javax.swing.JSpinner$DefaultEditor.commitEdit(JSpinner.java:859)
at javax.swing.JSpinner.commitEdit(JSpinner.java:527)
at javax.swing.plaf.basic.BasicSpinnerUI$ArrowButtonHandler.actionPerformed(BasicSpinnerUI.java:635)
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(BasicButtonListener.java:236)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
at java.awt.Component.processMouseEvent(Component.java:6289)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6054)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4652)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4482)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
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:2478)
at java.awt.Component.dispatchEvent(Component.java:4482)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:603)
at java.awt.EventQueue$1.run(EventQueue.java:601)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:617)
at java.awt.EventQueue$2.run(EventQueue.java:615)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java: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)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1