Load Dropbox files into JList Maven Java NetBeans? -


i have created maven netbeans project dropbox , need call files in folder dropox , display them in jlist on interface.

i able print them out in output using (system.out.println()) following:

public void getfiles()     {         try         {             mainempoperations mempops = new mainempoperations();             // files , folder metadata dropbox root directory             listfolderresult result = client.files().listfolder("/employees");             while (true) {                 (metadata metadata : result.getentries()) {                    system.out.println(metadata.getpathlower());                 }                 if (!result.gethasmore()) {                     break;                 }                 result = client.files().listfoldercontinue(result.getcursor());                             }         }         catch (exception e)         {             joptionpane.showmessagedialog(null, e);         }     } 

the coding have tried use loading files jlist similar above coding using defaultlistmodel.

here coding have done far not list files in jlist.

public void getfiles()     {         try         {             mainempoperations mempops = new mainempoperations();             // files , folder metadata dropbox root directory             listfolderresult result = client.files().listfolder("/employees");             defaultlistmodel modellistfiles = new defaultlistmodel();             while (true) {                 (metadata metadata : result.getentries()) {                     modellistfiles.addelement(metadata.getpathlower());                 }                 if (!result.gethasmore()) {                     break;                 }                 result = client.files().listfoldercontinue(result.getcursor());                                 mempops.list_cloudfiles.setmodel(modellistfiles);             }         }         catch (exception e)         {             joptionpane.showmessagedialog(null, e);         }     } 

please please me out, , me load files names of file jlist.

much appreciated

i managed figure out.

the way in needs work adding of element , setting of model need done straight after each other. placing set model after if statement results in model being cleared or becomes empty.

therefore following coding work listing of files in jlist. please note: rest of other coding needed connection , management dropbox on dropbox developers website.

coding works:

    public void getfiles()         {             try             {                 // files , folder metadata dropbox root directory                 //please note employees folder on dropbox                 listfolderresult result = client.files().listfolder("/employees");                 defaultlistmodel modellistfiles = new defaultlistmodel();                 while (true) {                     (metadata metadata : result.getentries()) {                         //get name returns name of file , getpathlower() used getting directory , filename together.                         modellistfiles.addelement(metadata.getname());                         list_cloudfiles.setmodel(modellistfiles);                     }                     if (!result.gethasmore()) {                         break;                     }                     result = client.files().listfoldercontinue(result.getcursor());                                 }             }             catch (exception e)             {                 joptionpane.showmessagedialog(null, e);             }         } 

like (upvote or mark helpful) if answer posted own question helps out well.


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -