hola, necesito ayuda con un proyecto en java....
me salen cuatro errores que no se quitarlos...
os pongo el codigo para que me intenteis ayudar... los errores son estos...
lstOrigen.addListSelectionListener(new ManejadorListaOrigen());
class ManejadorListaOrigen implements ListSelectionListener{
public void valueChanged(ListSelectionEvent e){
buses.reservaBilletes(lstOrigen.getSelectedValue() ,
aqui va el codigo de ese fichero entero para que lo intenteis ejecutar.
import javax.swing.*;
import java.awt.event.*;
import java.util.LinkedList;
import java.sql.*;
import java.util.Vector;
public class CarreterayManta extends JFrame implements WindowListener{
private String origenDatos= "//localhost:3306/Autobuses";
private String usuario= "root";
private String pass= "";
private String driver = "com.mysql.jdbc.Driver";
private String url = "jdbc:mysql:" + origenDatos;
private ResultSet rs;
private Statement st;
private Connection conexion=null;
private CarreterayManta buses = new CarreterayManta();
private JList lstOrigen = new JList();
private JList lstDestino = new JList();
private JButton btnReservar = new JButton("Reservar");
private JTextField txtFecha = new JTextField("dd/mm/aa");
private JTextField txtNumPasajeros = new JTextField();
private JFrame ventanaActual = this;
public CarreterayManta() {
super("Reserva de Billetes");
for(String s:buses.origenes())
lstOrigen.add(this);
ManejaEventoBoton manejaBoton = new ManejaEventoBoton();
btnReservar.addActionListener(manejaBoton);
txtFecha.addActionListener(manejaBoton);
txtNumPasajeros.addActionListener(manejaBoton);
lstOrigen.addListSelectionListener(new ManejadorListaOrigen());
this.pack();
this.setResizable(false);
this.setVisible(true);
}
public void windowOpened(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public void windowClosed(WindowEvent e) {}
public void windowIconified(WindowEvent e) {}
public void windowDeiconified(WindowEvent e) {}
public void windowActivated(WindowEvent e) {}
public void windowDeactivated(WindowEvent e) {}
class ManejaEventoBoton implements ActionListener {
public void actionPerformed(ActionEvent evt) {
try {
int numPasajeros=
Integer.parseInt(txtNumPasajeros.getText());
if (lstOrigen.getSelectedIndex()!=-1 &&
lstDestino.getSelectedIndex()!=-1) {
new Reserva(ventanaActual,numPasajeros);
}
} catch (NumberFormatException e) {
txtNumPasajeros.setText("Número incorrecto");
}
}
}
class ManejadorListaOrigen implements ListSelectionListener{
public void valueChanged(ListSelectionEvent e){
lstDestino.removeAll();
for(String s:buses.destinos(
lstOrigen.getName())) {
lstDestino.add(s, buses);
}
}
}
public void reservaBilletes(LinkedList<Viajero> pasajeros) {
try {
buses.reservaBilletes(lstOrigen.getSelectedValue() ,
lstDestino.getSelectedValue(), pasajeros,
txtFecha.getText());
} catch (Exception e) {
txtNumPasajeros.setText("No hay billetes disponibles");
}
}
public Vector<String> destinos (String origen){
Vector <String> aeropuertos=new Vector<String>();
if(conectar())
{
String consulta="select nombre from aeropuertos where id=(select idDestino from rutas where idOrigen=(select id from aeropuertos where nombre='"+origen+"'));";
try{
st=conexion.createStatement();
rs=st.executeQuery(consulta);
while(rs.next()){
aeropuertos.add(rs.getString("nombre"));
}
}
catch(SQLException se){}
}
return aeropuertos;
}
public Vector<String> origenes () {
Vector <String> aeropuertos=new Vector<String>();
if(conectar())
{
String consulta="select nombre from estaciones";
try{
st=conexion.createStatement();
rs=st.executeQuery(consulta);
while(rs.next()){
aeropuertos.add(rs.getString("nombre"));
}
}
catch(SQLException se){}
}
return aeropuertos;
}
public boolean reservaBilletes(String origen,String destino,Vector <Viajero> pasajeros, String fecha){
if(conectar())
{
String consulta="select plazaslibres from rutas where idOrigen='"+origen+"' and idDestino='"+destino+"' and fecha='"+fecha+"';";
try{
st=conexion.createStatement();
rs=st.executeQuery(consulta);
if(rs.next()){
if(rs.getInt("plazaslibres")<pasajeros.size())
return false;
else
{
consulta="select idRuta from rutas where idOrigen=(select id from aeropuertos where nombre='"+origen+"') and idDestino=(select id from aeropuertos where nombre='"+destino+"')";
rs=st.executeQuery(consulta);
int idRuta;
if(rs.next())
{
idRuta=rs.getInt("idRuta");
for (int i=0;i<pasajeros.size();i++)
{
consulta="insert into reservas (nombre,dni,idRuta) values ('"+pasajeros.elementAt(i).nombre()+"','"+pasajero s.elementAt(i).dni()+"',"+idRuta+");";
st.executeUpdate(consulta);
}
return true;
}
}
}
}
catch(SQLException se){}
}
return false;
}
public boolean conectar(){
try {
Class.forName(driver);
conexion = DriverManager.getConnection(url, usuario, pass);
}
catch (ClassNotFoundException ex) {
return false;
}
catch (SQLException ex) {
return false;
}
return true;
}
public boolean desconectar(){
try {
conexion.close();
} catch (SQLException ex) {
return false;
}
return true;
}
}



