public void displaychapter(int framenum, int labelnum) throws IOException
{
    
         chapdispframenum = framenum;
         labelnumber = labelnum;
         
         
           BufferedImage testimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
           File file = new File(filename);
           InputStream is = new FileInputStream(file);
           int seeknumRead=0;
           long frameoffset = chapdispframenum*sizeofframe;
           is.skip(frameoffset);
           
           
           int numRead = 0;
           int k = 0;
           byte[] bytes = new byte[(int)sizeofframe];
            if((numRead=is.read(bytes,  0, sizeofframe)) >=0) {
                     // VideoFrame[framenum] = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

                        for(int y = 0; y < height; y++){

                            for(int x = 0; x < width; x++){
                                byte a = 0;
                                byte r = bytes[k];
                                byte g = bytes[k+height*width];
                                byte b = bytes[k+height*width*2]; 
                                int pix = 0xff000000 | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
                                //int pix = ((a << 24) + (r << 16) + (g << 8) + b);
                                testimg.setRGB(x,y,pix);             
                                k++;
                            }//end of for x
                        }//end of for y
                                   
          // ImageIcon imgicon = new ImageIcon(testimg); 
         

              Image simg = testimg.getScaledInstance( 100, 100,  java.awt.Image.SCALE_SMOOTH ) ;
              ImageIcon imgiconscaled = new ImageIcon(simg);
 

                int chapnum = framenum;//(framenum/Vplayer.chapterspan);
                int untilchapnum = framenum+(Vplayer.chapterspan-1);
                
                
                switch(labelnumber)
                {
                    
                    case 1:Vplayer.chapLabel1.setIcon(imgiconscaled); 
                           Vplayer.jFormattedTextField1.setText(""+chapnum+"-"+untilchapnum);
                           Vplayer.chapLabel1_frameno = framenum;    break;
                        
                        
                    case 2:Vplayer.chapLabel2.setIcon(imgiconscaled);  
                           Vplayer.chapLabel2_frameno = framenum;  
                           Vplayer.jFormattedTextField2.setText(""+chapnum+"-"+untilchapnum);
                           break;
                    case 3:Vplayer.chapLabel3.setIcon(imgiconscaled);  
                           Vplayer.chapLabel3_frameno = framenum;   
                           Vplayer.jFormattedTextField3.setText(""+chapnum+"-"+untilchapnum);
                           break;
                        
                    case 4:Vplayer.chapLabel4.setIcon(imgiconscaled);  
                           Vplayer.chapLabel4_frameno = framenum; 
                           Vplayer.jFormattedTextField4.setText(""+chapnum+"-"+untilchapnum);
                           break;
                        
                    case 5:Vplayer.chapLabel5.setIcon(imgiconscaled); 
                           Vplayer.chapLabel5_frameno = framenum;  
                           Vplayer.jFormattedTextField5.setText(""+chapnum+"-"+untilchapnum);
                           break;
                    //case 6:Vplayer.videolabel.setIcon(imgicon);      break; //this one is for main frame
                    default: break;
                }       
                        
            }//end of if    
            
            else
            {
                System.out.println("Something went wrong. number of bytes read = numRead= "+numRead);
            }
            
 // System.out.println("END OF DISPLAY CHAPTER THREAD: chapter displayed ="+chapdispframenum+"on label:"+labelnumber);           
            
}