-2

I'm working in android/desktop application using backendless to share data between my PC and my Android device.

I've created a class in backendlass which contains 2 columns "Name" "Url" (both are strings)

I want to retrieve the data of this class in a JTable, but I don't know how to start that

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Bensaad
  • 45
  • 1
  • 7
  • 3
    Start with tutorials on [`JTable`](https://docs.oracle.com/javase/tutorial/uiswing/components/table.html) and [JDBC™](https://docs.oracle.com/javase/tutorial/jdbc/). – Catalina Island Apr 01 '16 at 15:43
  • okay thanks I'll read this, it's just that I used to develop for android using Parse.com and I only have 2 weeks with backendless and Swing – Bensaad Apr 01 '16 at 17:49

1 Answers1

0

So I found the answer by myself, I'm writing the code here if someone else need it :

Let's say you have a contact object with a name and phonenumber (both strings) and you want to show them on a JTable retrieving the name and the number from backendless :

public void retrieveInformation(BackendlessDataQuery query,final DefaultTableModel model){
    System.out.println("Retrieving Data...");
    Backendless.Data.of(Contact.class).find(query, new AsyncCallback<BackendlessCollection<Contact>>() {

        @Override
        public void handleResponse(BackendlessCollection<Contact> backendlessCollection) {


             Object[] row = new Object[2];
             for (Contact map : backendlessCollection.getCurrentPage()){
                 row[0] = map.getName();
                 row[1] = map.getNumber();
                 model.addRow(row);
                 System.out.println("Retrieving Data complete !");
             }


        }

        @Override
        public void handleFault(BackendlessFault backendlessFault) {
            System.out.println(backendlessFault.getMessage());
        }
    });}
Bensaad
  • 45
  • 1
  • 7