Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/08/2012, 17:35
OscarSoftwares
 
Fecha de Ingreso: julio-2012
Ubicación: Distrito Federal
Mensajes: 7
Antigüedad: 11 años, 9 meses
Puntos: 0
Pregunta Heredar clases java con netbeans

Hola buenas tardes les comento soy nuevo en esto de la programación en java por lo regular siempre programo en .net pero ahora me llamo la atención aprender un poco de java en fin estoy intentando de Heredar clases pero me sale el siguiente error an enclosing instance that contains newclase.Datos.Trillas is required

les muestro el codigo fuente de la clase :

Código Javascript:
Ver original
  1. public class Datos
  2. {
  3.    
  4.  
  5.    public  boolean registro; // DECLARO VARIABLES GLOBALES
  6.    public String libro;
  7.    public String editorial;
  8.    public String Autor;
  9.    public int edicion;
  10.  public void newlibro(String nlibro,int nedicion,String Autor,String editorial)
  11.  {
  12.   this.libro=nlibro; //IGUALO LAS VARIABLES
  13.   this.Autor=Autor;
  14.   this.edicion=nedicion;
  15.   this.editorial=editorial;
  16.  
  17.  System.out.println("NUEVO LIBRO REGISTRADO"+this.libro); //IMPRIMO EL RESULTADO
  18.  System.out.println("EDICION"+this.Autor);
  19.  System.out.println("AUTOR"+this.edicion);
  20.  System.out.println("AUTOR"+this.editorial);
  21.  registro=true;
  22.  }
  23.  public void deletelibro(String nlibro)
  24.  {
  25.      
  26.     if(nlibro.trim().equals("")|| nlibro.trim()=="")
  27.     JOptionPane.showMessageDialog(null,"LA VARIABLE LIBRO ESTA VACIA","VARIABLE LIBRO VACIA",JOptionPane.ERROR_MESSAGE);
  28.     //VERIFICO SI ESTA VACIA O NO
  29.     else
  30.         registro=false;
  31.         System.out.println("LIBRO BORRADO EXITOSAMENTE :D");
  32.  }
  33. class Trillas extends Datos // CREO LA SUBCLASE
  34.  {
  35.     public Trillas()
  36.     {
  37.         this.editorial="TRILLAS";
  38.     }
  39.     public void editorial()
  40.     {
  41.         System.out.println("LA EDITORIAL ES"+""+this.editorial);
  42.     }
  43.  }

Y Finalmente en el main de mi proyecto tengo el siguiente codigo fuente:

Código Javascript:
Ver original
  1. */
  2. package newclase;
  3. import newclase.Datos;
  4. import javax.swing.JOptionPane;
  5. public class NewClase {
  6.  
  7.     /**
  8.      * @param args the command line arguments
  9.      */
  10.     public static void main(String[] args)
  11.     {
  12.     String op;
  13.     Datos libros = new Datos(); // DECLARO LA NUEVA INSTANCIA
  14.     op=JOptionPane.showInputDialog(null,"ELIGE OPCION");
  15.     switch(op)
  16.     {
  17.        
  18.         case "1":
  19.        String dlete=JOptionPane.showInputDialog(null,"INSERTE EL TITULO LIBRO","TITULO",JOptionPane.INFORMATION_MESSAGE);
  20.             libros.deletelibro(dlete);
  21.  
  22.     break;
  23.  
  24.         case "2":
  25.    
  26. [B]Trillas os = new Trillas(); //ERRROR [/B]
  27. break ;
  28.      
  29.     }
  30.    
  31.    
  32.     }

Pero como les comentaba tengo el error al intentar hacer esto: Trillas os = new Trillas(); //ERRROR espero y me puedan ayudar he intentado toda la tarde y no doy una y por ultimo utilizo netbeans IDE 7.1.2 GRACIAS