Results 1 to 2 of 2
  1. #1
    Nazneen Ali is offline Senior Member
    Join Date
    Jul 2011
    Rep Power

    Default void type not allowed here

    Java Code:
    private void jButtonReadActionPerformed(java.awt.event.ActionEvent evt) {
    DNA d1=new DNA();
    While getText(), getSeq(), readFromFile() all DO have the return type String.

    The code for these methods is as follows:

    Java Code:
    String readFromFile(String path){
           String stringFromFile= new String();
               FileReader fro = new FileReader( path );
               BufferedReader bro = new BufferedReader( fro );
              String strline= bro.readLine( );
              stringFromFile= "";
              while( strline!= null )
              {  stringFromFile+= strline;
              strline= bro.readLine( );
              bro.close( );}
           catch( FileNotFoundException filenotfoundexxption)
               System.out.println( "FastaDNA.txt, does not exist" );
           catch( IOException ioexception)
               ioexception.printStackTrace( );
           System.out.println("To test if the file, FastaDNA.text located in G drive, has been read:\nSEQUENCE NAME:" + stringFromFile.substring(0, stringFromFile.indexOf(">")));
           System.out.println("SEQUENCE:"+ stringFromFile.substring(stringFromFile.indexOf(">")+1,stringFromFile.length()));
    return stringFromFile;

    Java Code:
     String getName(){
        return JOptionPane.showInputDialog(this,"Name of the sequence:");
    Java Code:
    String getSeq(){
        return JOptionPane.showInputDialog(this,"Sequence:");

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Richmond, Virginia
    Blog Entries
    Rep Power


    setText returns void, the method most likely takes some argument. readFromFile(...) expects a string, but what you are passing in is a call to setText(...)

Similar Threads

  1. Replies: 8
    Last Post: 05-25-2011, 07:26 PM
  2. void type not allowed
    By jockhip12 in forum New To Java
    Replies: 6
    Last Post: 05-05-2011, 06:26 PM
  3. 'void' type not allowed here
    By Torgero in forum New To Java
    Replies: 15
    Last Post: 10-05-2008, 12:08 AM
  4. Replies: 5
    Last Post: 01-25-2008, 12:53 AM
  5. is void a type?
    By mary in forum New To Java
    Replies: 3
    Last Post: 08-01-2007, 09:12 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts