Foros del Web » Programación para mayores de 30 ;) » Java »

Que significa este error?

Estas en el tema de Que significa este error? en el foro de Java en Foros del Web. Me encargaron realizar una casa de cambio con botones de radio y pues eclipse no me tira errores al compilarse automáticamente, pero al ejecutarse y ...
  #1 (permalink)  
Antiguo 20/04/2011, 16:14
 
Fecha de Ingreso: abril-2011
Mensajes: 2
Antigüedad: 13 años
Puntos: 0
Que significa este error?

Me encargaron realizar una casa de cambio con botones de radio y pues eclipse no me tira errores al compilarse automáticamente, pero al ejecutarse y le doy click a algun botón de radio me tira un error

Clases:
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.awt.event.ItemEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;


public class casa_cambio_adrian extends JFrame {
//Declarar variables
private JTextField campo;
private JTextField resp;
private JRadioButton peseu;
private JRadioButton eupes;
private JRadioButton dolpes;
private JRadioButton pesdol;
private ButtonGroup grupo;
private JButton salir;
private JLabel ins;

public casa_cambio_adrian(){
//Ventana
setLayout(new FlowLayout());
setSize(480,190);
setResizable(false);

//Instanciar variables
ins = new JLabel ("Que conversion desea hacer? (antes introduzca la cotizacion del euro y del dolar");
peseu=new JRadioButton ("Pesos a euros");
eupes=new JRadioButton ("Euros a pesos");
dolpes=new JRadioButton ("Dolares a pesos");
pesdol=new JRadioButton("Pesos a dolares");
campo=new JTextField(20);
grupo=new ButtonGroup();
salir=new JButton("Salir");
resp=new JTextField("Respuesta");

//Meter botones de radio al mismo grupo
grupo.add(peseu);
grupo.add(eupes);
grupo.add(dolpes);
grupo.add(pesdol);

//Agregar variables ala ventana
add(ins);
add(peseu);
add(eupes);
add(dolpes);
add(pesdol);
add(campo);
add(salir);
add(resp);

Controlboton control = new Controlboton();
peseu.addItemListener(control);
eupes.addItemListener(control);
dolpes.addItemListener(control);
pesdol.addItemListener(control);

//double cot_dolar=Double.parseDouble(JOptionPane.showInput Dialog(null,"Introduzca la cotizacion del dolar","Dólar",JOptionPane.QUESTION_MESSAGE));
//double cot_euros=Double.parseDouble(JOptionPane.showInput Dialog(null,"Introduzca la cotizacion del euro","Euro",JOptionPane.QUESTION_MESSAGE));
salir.addActionListener(new ActionListener()
{

public void actionPerformed(final ActionEvent e)
{
System.exit(0);
}
});
}

private class Controlboton implements ItemListener
{


public void itemStateChanged(ItemEvent control)
{
if(control.getSource()==peseu){
double numero=Double.parseDouble(campo.getText());

double res= numero/10;
String ress=Double.toString(res);
resp.setText("hola");
}
if(control.getSource()==eupes){
double numero=Double.parseDouble(campo.getText());

double res= numero*10;
String ress=Double.toString(res);
resp.setText(ress);
}

else if(control.getSource()==dolpes) {
double numero=Double.parseDouble(campo.getText());

double res= numero*10;
String ress=Double.toString(res);
resp.setText(ress);
}
else
if(control.getSource()==pesdol) {
double numero=Double.parseDouble(campo.getText());

double res= numero/10;
String ress=Double.toString(res);
resp.setText(ress);
}








}
}
}


import javax.swing.*;
public class casa_adrian {


public static void main (String args[]){

casa_cambio_adrian ventana=new casa_cambio_adrian();
ventana.setTitle("Casa de Cambio");
ventana.setLocationRelativeTo(null); //Centra la ventana en la pantalla
ventana.setVisible(true);
ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CL OSE);
}
}






ERRORES:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(Unkn own Source)
at java.lang.Double.parseDouble(Unknown Source)
at PROG_INFO.casa_cambio_adrian$Controlboton.itemStat eChanged(casa_cambio_adrian.java:101)
at javax.swing.AbstractButton.fireItemStateChanged(Un known Source)
at javax.swing.AbstractButton$Handler.itemStateChange d(Unknown Source)
at javax.swing.DefaultButtonModel.fireItemStateChange d(Unknown Source)
at javax.swing.JToggleButton$ToggleButtonModel.setSel ected(Unknown Source)
at javax.swing.ButtonGroup.setSelected(Unknown Source)
at javax.swing.JToggleButton$ToggleButtonModel.setSel ected(Unknown Source)
at javax.swing.JToggleButton$ToggleButtonModel.setPre ssed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
  #2 (permalink)  
Antiguo 20/04/2011, 16:15
 
Fecha de Ingreso: abril-2011
Mensajes: 2
Antigüedad: 13 años
Puntos: 0
Respuesta: Que significa este error?

se que algunas impresiones no tienen sentido, eran pruebas, asi que concentremonos en los errores de ejecución por favor.
  #3 (permalink)  
Antiguo 20/04/2011, 19:24
 
Fecha de Ingreso: septiembre-2008
Ubicación: Córdoba
Mensajes: 67
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Que significa este error?

Has tratado de analizar el error que te tira?

Cita:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(Unkn own Source)
at java.lang.Double.parseDouble(Unknown Source)
at PROG_INFO.casa_cambio_adrian$Controlboton.itemStat eChanged(casa_cambio_adrian.java:101)
Más claro, echale agua!!

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:22.