Java - Problemas al realizar un menu

 
Vista:

Problemas al realizar un menu

Publicado por Yo mismo (20 intervenciones) el 31/07/2008 12:38:29
Tengo el siguiente manejador de eventos de un menu, no se porque pero en la linea donde mando ocultar el panel actual me da un error y no se xke...alguien me ayuda...este es el codigo:

public class GestionMenu implements ActionListener{
private Ventana ventanaprincipal;
private JPanel panel;
private PanelLogin login;
private PanelVerCliente clientes;
private PanelDatos datos;
private PanelDescuento descuento;
private Cliente cl;
private PanelEnvio envio;
private PanelBuscarCliente buscar;
private PanelOpciones opciones;
private PanelOpcionesGestor gestor;
private PanelBuscarEnvio buscaren;
/**
*
* @param interfaz Ventana donde pegamos los paneles
* @param panel Panel actual donde nos encontramos
*/
public GestionMenu(Ventana interfaz,JPanel panel){
this.ventanaprincipal=interfaz;
this.panel=panel;


}
public void actionPerformed(ActionEvent evento) {
if(evento.getSource().equals(this.ventanaprincipal.getSalir())) {
System.exit(0);
}
if(evento.getSource().equals(this.ventanaprincipal.getCerrar())){
PanelLogin login=new PanelLogin(this.ventanaprincipal);
this.ventanaprincipal.add(login);
login.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(login);
this.ventanaprincipal.setCliente(new Cliente());
this.ventanaprincipal.setGestor(new Gestor());
this.login.setPanel(login);
}
if(evento.getSource().equals(this.ventanaprincipal.getMenuC())){
if((this.ventanaprincipal.getCliente().getEsGestor())==1){
JOptionPane.showMessageDialog(null,
"Opcion valida unicamente para el cliente",
"Error",
JOptionPane.ERROR_MESSAGE);
}
else{
this.opciones=new PanelOpciones(this.ventanaprincipal);
this.ventanaprincipal.add(opciones);
this.opciones.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(opciones);
}
}
if(evento.getSource().equals(this.ventanaprincipal.getMenuG())){
if((this.ventanaprincipal.getCliente().getEsGestor())==0){
JOptionPane.showMessageDialog(null,
"Opcion valida unicamente para el gestor",
"Error",
JOptionPane.ERROR_MESSAGE);
}
else{
this.gestor=new PanelOpcionesGestor(this.ventanaprincipal);
this.ventanaprincipal.add(gestor);
this.gestor.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(gestor);
}
}
if(evento.getSource().equals(this.ventanaprincipal.getVerDatosClientes())){
if((this.ventanaprincipal.getCliente().getEsGestor())==0){
JOptionPane.showMessageDialog(null,
"Opcion valida unicamente para el gestor",
"Error",
JOptionPane.ERROR_MESSAGE);
}
else{
this.buscar=new PanelBuscarCliente(this.ventanaprincipal);
this.ventanaprincipal.add(buscar);
this.buscar.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(buscar);
}
}
if(evento.getSource().equals(this.ventanaprincipal.getVerMisDatos())){
if((this.ventanaprincipal.getCliente().getEsGestor())==0){
this.datos=new PanelDatos(this.ventanaprincipal);
this.ventanaprincipal.add(datos);
this.datos.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(datos);
}
else{
JOptionPane.showMessageDialog(null,
"Opcion valida unicamente para el cliente",
"Error",
JOptionPane.ERROR_MESSAGE);
}
}
if(evento.getSource().equals(this.ventanaprincipal.getRealizarEnvio())){
if((this.ventanaprincipal.getCliente().getEsGestor())==0){
this.envio=new PanelEnvio(this.ventanaprincipal);
this.ventanaprincipal.add(envio);
this.envio.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(envio);
}
else{
JOptionPane.showMessageDialog(null,
"Opcion valida unicamente para el cliente",
"Error",
JOptionPane.ERROR_MESSAGE);
}
}
if(evento.getSource().equals(this.ventanaprincipal.getRealizarDescuento())){
if((this.ventanaprincipal.getCliente().getEsGestor())==1){
this.descuento=new PanelDescuento(this.ventanaprincipal);
this.ventanaprincipal.add(descuento);
this.descuento.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(descuento);
}
else{
JOptionPane.showMessageDialog(null,
"Opcion valida unicamente para el gestor",
"Error",
JOptionPane.ERROR_MESSAGE);
}
}
if(evento.getSource().equals(this.ventanaprincipal.getVerEnvios())){
if((this.ventanaprincipal.getCliente().getEsGestor())==1){
this.buscaren=new PanelBuscarEnvio(this.ventanaprincipal);
this.ventanaprincipal.add(buscaren);
this.buscaren.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(buscaren);
}
else{
JOptionPane.showMessageDialog(null,
"Opcion valida unicamente para el gestor",
"Error",
JOptionPane.ERROR_MESSAGE);
}
}
if(evento.getSource().equals(this.ventanaprincipal.getVerEnviosCl())){
if((this.ventanaprincipal.getCliente().getEsGestor())==0){
this.buscaren=new PanelBuscarEnvio(this.ventanaprincipal);
this.ventanaprincipal.add(buscaren);
this.buscaren.setVisible(true);
this.ventanaprincipal.getPanel().setVisible(false);
this.ventanaprincipal.setPanel(buscaren);
}
else{
JOptionPane.showMessageDialog(null,
"Opcion valida unicamente para el cliente",
"Error",
JOptionPane.ERROR_MESSAGE);
}
}
}
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Problemas al realizar un menu

Publicado por Mario (199 intervenciones) el 31/07/2008 12:46:07
E qué linea exactamente? Te devuelve un mensaje?? cual??
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Problemas al realizar un menu

Publicado por Yo mismo (20 intervenciones) el 31/07/2008 22:45:39
Tranquilo...lo he solucionado ya,el problema me daba en el setPanel y era porque no fijaba en que panel estaba en cada momento...Gracias por preocuparte de todas maneras
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar