error en codigo
Publicado por Christian (7 intervenciones) el 22/05/2006 00:30:56
me tira un error al crear new controlador
public class VistaTest {
public void main(String[] args) {
Vista v = new Vista ();
Modelo m = new Modelo();
Controlador c = new Controlador(v,m);//esta linea me
da error el resto sin problemas
}
}
--------------------------------
public class Modelo {
public boolean espar(int i) {
if (i%2==0) {
return true;
}
else{
return false;
}
}
}
-----------------------------------
import javax.swing.*;
public class Vista extends JFrame {
JButton boton;
JLabel etiqueta;
JTextField texto;
public Vista (){
boton = new JButton("OK");
etiqueta = new JLabel("RESPUESTA");
texto = new JTextField("PRUEBA");
this.getContentPane().add(boton,"Center");
this.getContentPane().add(etiqueta,"East");
this.getContentPane().add(texto,"North");
this.setVisible(true);
this.setSize(200,200);
}
}
-----------------------------
import java.awt.event.*;
public abstract class Controlador implements ActionListener {
Modelo m;
Vista v;
public Controlador (Vista vi,Modelo mo){
v = vi;
m = mo;
v.boton.addActionListener(this);
}
public void ActionPerformed (ActionEvent e){
String texto = v.texto.getText();
int numero = Integer.parseInt(texto);
if (m.espar(numero)){
v.etiqueta.setText("Es Par");
}
else{
v.etiqueta.setText("No es Par");
}
}
}
me pueden dar una mano ??
public class VistaTest {
public void main(String[] args) {
Vista v = new Vista ();
Modelo m = new Modelo();
Controlador c = new Controlador(v,m);//esta linea me
da error el resto sin problemas
}
}
--------------------------------
public class Modelo {
public boolean espar(int i) {
if (i%2==0) {
return true;
}
else{
return false;
}
}
}
-----------------------------------
import javax.swing.*;
public class Vista extends JFrame {
JButton boton;
JLabel etiqueta;
JTextField texto;
public Vista (){
boton = new JButton("OK");
etiqueta = new JLabel("RESPUESTA");
texto = new JTextField("PRUEBA");
this.getContentPane().add(boton,"Center");
this.getContentPane().add(etiqueta,"East");
this.getContentPane().add(texto,"North");
this.setVisible(true);
this.setSize(200,200);
}
}
-----------------------------
import java.awt.event.*;
public abstract class Controlador implements ActionListener {
Modelo m;
Vista v;
public Controlador (Vista vi,Modelo mo){
v = vi;
m = mo;
v.boton.addActionListener(this);
}
public void ActionPerformed (ActionEvent e){
String texto = v.texto.getText();
int numero = Integer.parseInt(texto);
if (m.espar(numero)){
v.etiqueta.setText("Es Par");
}
else{
v.etiqueta.setText("No es Par");
}
}
}
me pueden dar una mano ??
Valora esta pregunta
0