Example usage for com.google.gson JsonArray size

List of usage examples for com.google.gson JsonArray size

Introduction

In this page you can find the example usage for com.google.gson JsonArray size.

Prototype

public int size() 

Source Link

Document

Returns the number of elements in the array.

Usage

From source file:Plugins.java

License:Apache License

public void getPlugins() {
    try {//from  w  w w  .ja v  a 2  s  . c  om
        Iterator<TwisterPluginInterface> iterator = RunnerPluginsLoader.getPlugins();
        TwisterPluginInterface plugin = null;
        String name;
        JsonArray pluginsarray;
        int size;
        String pluginname;
        while (iterator.hasNext()) {
            try {
                plugin = iterator.next();
            } catch (Exception e) {
                System.out.println("Could not instatiate plugin");
                e.printStackTrace();
                continue;
            }
            name = plugin.getFileName();
            pluginsarray = RunnerRepository.getPlugins().getAsJsonArray();
            size = pluginsarray.size();
            for (int i = 0; i < size; i++) {
                pluginname = pluginsarray.get(i).getAsString();
                if (pluginname.equals(name) && (plugins.get(pluginname) == null)) {
                    plugins.put(pluginname, plugin);
                    break;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Plugins.java

License:Apache License

public void copyPreConfiguredPlugins() {
    try {/*from w w w . jav  a  2s.  com*/
        JsonArray plugins = RunnerRepository.getPlugins().getAsJsonArray();
        int size = plugins.size();
        String pluginfile;
        File pluginsfolder = new File(RunnerRepository.PLUGINSDIRECTORY);
        String[] localplugins = pluginsfolder.list();
        boolean found;
        for (int i = 0; i < size; i++) {
            pluginfile = plugins.get(i).getAsString();
            found = false;
            for (String file : localplugins) {
                if (file.equals(pluginfile)) {
                    File myfile = new File(
                            RunnerRepository.PLUGINSDIRECTORY + RunnerRepository.getBar() + pluginfile);
                    try {
                        ch.cd(RunnerRepository.REMOTEPLUGINSDIR);
                    } catch (Exception e) {
                        System.out.println("Could not get :" + RunnerRepository.REMOTEPLUGINSDIR
                                + " as remote plugins dir");
                    }
                    try {
                        long remotesize = ch.lstat(pluginfile).getSize();
                        long localsize = myfile.length();
                        if (remotesize == localsize)
                            found = true;
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
                }
            }
            if (!found) {
                copyPlugin(pluginfile);
            }
        }
    } catch (Exception e) {
        System.out.println("Could not get Plugins Array from local config");
        e.printStackTrace();
    }
}

From source file:Plugins.java

License:Apache License

public void loadRemotePluginList() {
    String[] downloadedplugins = null;
    File pluginsfile = new File(RunnerRepository.PLUGINSDIRECTORY);
    if (pluginsfile.exists())
        downloadedplugins = pluginsfile.list();
    ArrayList<String> list = getRemotePlugins();
    JPanel panel;/*from   w  ww. j av a2 s  . c  om*/
    JLabel lname;
    for (String name : list) {
        if (name.indexOf(".jar") == -1)
            continue;
        final String tempname = name;
        lname = new JLabel(name);
        lname.setBackground(Color.WHITE);
        final MyButton addremove = new MyButton("Download");
        addremove.setMyLabel(lname);
        for (String localfile : downloadedplugins) {
            if (name.equals(localfile)) {
                JsonArray pluginsarray;
                String pluginname;
                pluginsarray = RunnerRepository.getPlugins().getAsJsonArray();
                int size = pluginsarray.size();
                for (int i = 0; i < size; i++) {
                    pluginname = pluginsarray.get(i).getAsString();
                    if (name.equals(pluginname)) {
                        addremove.setText("Remove");
                        break;
                    }
                }
            }
        }
        if (addremove.getText().equals("Remove")) {
            GridBagConstraints gridBagConstraints = new GridBagConstraints();
            gridBagConstraints.gridx = 1;
            if (PermissionValidator.canChangePlugins()) {
                localtable.add(addremove, gridBagConstraints);
            }
            gridBagConstraints.gridx = 0;
            localtable.add(lname, gridBagConstraints);
            int height = localtable.getComponentCount() * 40;
            localtable.setPreferredSize(new Dimension(240, height));
        } else {
            GridBagConstraints gridBagConstraints = new GridBagConstraints();
            gridBagConstraints.gridx = 1;
            if (PermissionValidator.canChangePlugins()) {
                remotetable2.add(addremove, gridBagConstraints);
            }

            gridBagConstraints.gridx = 0;
            remotetable2.add(lname, gridBagConstraints);
        }
        addremove.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ev) {
                addRemovePlugin(addremove, tempname);
            }
        });
    }
}

From source file:Plugins.java

License:Apache License

public static void deletePlugins() {
    File pluginsdirectory = new File(RunnerRepository.PLUGINSDIRECTORY);
    File[] downloadedplugins = pluginsdirectory.listFiles();
    boolean found;
    int size;/*from  www  .  j ava2  s. com*/
    String plugin;
    for (File availableplugin : downloadedplugins) {
        found = false;
        JsonArray plugins = null;
        try {
            plugins = RunnerRepository.getPlugins().getAsJsonArray();
        } catch (Exception e) {
            System.out.println("Plugins list from config file is empty ");
            return;
        }
        size = plugins.size();
        for (int i = 0; i < size; i++) {
            plugin = plugins.get(i).getAsString();
            //                 if(!availableplugin.getName().equals("Twister.jar") &&
            //                     availableplugin.getName().equals(plugin)){
            if (availableplugin.getName().equals(plugin.substring(0, plugin.indexOf(".")) + "_description.txt")
                    || availableplugin.getName().equals(plugin)) {
                found = true;
                break;
            }
        }
        if (!found) {
            availableplugin.delete();
        }
    }
}

From source file:EAIJSONConverter.java

License:Open Source License

public static SiebelPropertySet JsonObjectToPropertySet(JsonObject obj, SiebelPropertySet ps) {
    Iterator<Entry<String, JsonElement>> iterator = obj.entrySet().iterator();
    SiebelPropertySet child;//from   w  w  w  . j  a  va2 s.  com
    while (iterator.hasNext()) {
        JsonArray jsonArray = new JsonArray();
        JsonObject jsonObject = new JsonObject();
        Map.Entry mapEntry = (Map.Entry) iterator.next();
        if (mapEntry != null) {
            JsonElement jsonelement = (JsonElement) mapEntry.getValue();
            if (jsonelement.isJsonArray()) {
                jsonArray = jsonelement.getAsJsonArray();
                child = new SiebelPropertySet();
                child.setType("ListOf-" + mapEntry.getKey().toString());
                for (int i = 0; i < jsonArray.size(); i++) {
                    if (jsonArray.get(i).isJsonObject() || jsonArray.get(i).isJsonArray()) {
                        SiebelPropertySet temp = new SiebelPropertySet();
                        temp.setType("" + i);
                        if (jsonArray.get(i).isJsonObject())
                            child.addChild(JsonObjectToPropertySet(jsonArray.get(i).getAsJsonObject(), temp));
                        else {
                            JsonObject aux = new JsonObject();
                            aux.add("" + i, jsonArray.get(i));
                            child.addChild(JsonObjectToPropertySet(aux, temp));

                        }
                    } else
                        child.setProperty("" + i, jsonArray.get(i).getAsString());
                }
                ps.addChild(child);
            } else if (jsonelement.isJsonObject()) {
                jsonObject = jsonelement.getAsJsonObject();
                child = new SiebelPropertySet();
                child.setType(mapEntry.getKey().toString());
                ps.addChild(JsonObjectToPropertySet(jsonObject, child));
            } else {
                ps.setProperty(mapEntry.getKey().toString(), mapEntry.getValue().toString());
            }
        }
    }

    return ps;
}

From source file:accessControl.AuthAPIService.java

License:Open Source License

public ArrayList<Path> getAvailablePaths(String subjectInfo, boolean isCertificate) {

    HttpURLConnection connection = null;
    try {//from w w w.j  av a 2  s .c o  m
        //Create connection
        String finalURL = authServiceURI + "?getPaths=true";
        logger.debug("Sending request. URI:" + finalURL);
        URL url = new URL(finalURL);
        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/json");

        if (!isCertificate)
            connection.setRequestProperty("Cookie", subjectInfo);

        connection.setUseCaches(false);
        connection.setDoOutput(true);
        connection.connect();

        if (isCertificate) {
            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
            wr.writeBytes(subjectInfo);
            wr.flush();
            wr.close();
        }

        //Get Response
        InputStream is = connection.getInputStream();
        BufferedReader rd = new BufferedReader(new InputStreamReader(is));
        StringBuilder response = new StringBuilder(); // or StringBuffer if not Java 5+
        String line;
        while ((line = rd.readLine()) != null) {
            response.append(line);
        }
        rd.close();

        String response_result = response.toString();

        // If the whole tree is allowed (administrator mode)
        // We need this since the list of administrators is stored on AC side
        if (response_result.equalsIgnoreCase("true")) {
            ArrayList<Path> res = new ArrayList<>();
            res.add(new Path("all"));
            return res;
        } else if (response_result.equalsIgnoreCase("false"))
            return null;

        // Parse the paths and return them
        JsonObject paths = new JsonParser().parse(response_result).getAsJsonObject();
        JsonArray json_paths = paths.getAsJsonArray("paths");

        ArrayList<Path> finalPaths = new ArrayList<>(json_paths.size());

        logger.debug(json_paths.size() + " PATHS FOUND");

        for (int i = 0; i < json_paths.size(); i++) {
            String pathString = json_paths.get(i).getAsString();
            logger.debug(pathString);
            Path nextPath = new Path(pathString);
            finalPaths.add(nextPath);
        }

        return finalPaths;

    } catch (Exception e) {
        logger.error("During getAvailablePaths request", e);
        return null;
    } finally {
        if (connection != null) {
            connection.disconnect();
        }
    }
}

From source file:account.PurchsaeReturnRegisterDetailAccount.java

private void jbtnViewActionPerformedRoutine() {
    try {//from  w  w  w  .ja  v a 2s  .  c om
        AccountAPI accountAPI = lb.getRetrofit().create(AccountAPI.class);

        if (ac_cd == null) {
            ac_cd = "";
        }
        if (!jCheckBox1.isSelected()) {
            ac_cd = "";
        }
        JsonObject call = accountAPI.PurchaseReturnRegisterAccount(jComboBox1.getSelectedIndex(),
                jComboBox3.getSelectedIndex(), lb.ConvertDateFormetForDB(jtxtFromDate.getText()),
                lb.ConvertDateFormetForDB(jtxtToDate.getText()), ac_cd).execute().body();

        lb.addGlassPane(this);
        if (call != null) {
            JsonObject result = call;
            if (result.get("result").getAsInt() == 1) {
                JsonArray array = call.getAsJsonArray("data");
                dtm.setRowCount(0);
                dtm.setRowCount(0);
                double cash = 0.00, bank = 0.00, card = 0.00;
                String tax_name = "";
                for (int i = 0; i < array.size(); i++) {
                    Vector row = new Vector();
                    row.add(array.get(i).getAsJsonObject().get("ref_no").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("v_type").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("inv_no").getAsString());
                    row.add(lb.ConvertDateFormetForDisplay(
                            array.get(i).getAsJsonObject().get("v_date").getAsString()));
                    row.add(array.get(i).getAsJsonObject().get("fname").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("SR_ALIAS").getAsString());
                    cash = array.get(i).getAsJsonObject().get("CASH_AMT").getAsDouble();
                    bank = array.get(i).getAsJsonObject().get("BANK_AMT").getAsDouble();
                    card = array.get(i).getAsJsonObject().get("CARD_AMT").getAsDouble();
                    tax_name = array.get(i).getAsJsonObject().get("tax_name").getAsString();
                    row.add(array.get(i).getAsJsonObject().get("SR_NAME").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("IMEI_NO").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("SERAIL_NO").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("QTY").getAsInt());
                    row.add(array.get(i).getAsJsonObject().get("RATE").getAsDouble());
                    row.add(array.get(i).getAsJsonObject().get("BASIC_ITEM_AMT").getAsDouble());
                    row.add(array.get(i).getAsJsonObject().get("tax_amt").getAsDouble());
                    row.add(array.get(i).getAsJsonObject().get("add_tax_amt").getAsDouble());
                    row.add(array.get(i).getAsJsonObject().get("DISC_RATE").getAsDouble());
                    row.add(array.get(i).getAsJsonObject().get("MRP").getAsDouble());
                    row.add(array.get(i).getAsJsonObject().get("AMT").getAsDouble());
                    row.add(array.get(i).getAsJsonObject().get("net_amt").getAsDouble());
                    row.add(tax_name);
                    row.add(cash);
                    row.add(bank);
                    row.add(card);
                    row.add(array.get(i).getAsJsonObject().get("bajaj_amt").getAsDouble());
                    row.add(lb.Convert2DecFmtForRs(
                            array.get(i).getAsJsonObject().get("net_amt").getAsDouble() - cash - bank - card
                                    - array.get(i).getAsJsonObject().get("bajaj_amt").getAsDouble()));
                    row.add(Constants.BRANCH.get(array.get(i).getAsJsonObject().get("branch_cd").getAsInt() - 1)
                            .getBranch_name());
                    dtm.addRow(row);
                }
                lb.setColumnSizeForTable(jTable1, jPanel1.getWidth());
                lb.removeGlassPane(PurchsaeReturnRegisterDetailAccount.this);
            } else {
                lb.removeGlassPane(PurchsaeReturnRegisterDetailAccount.this);
                lb.showMessageDailog(call.get("Cause").getAsString());
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(PurchsaeReturnRegisterDetailAccount.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:account.SalesRegisterCardWise.java

private void jbtnViewActionPerformedRoutine() {
    try {/*from w  ww.j a  va2s . c  o m*/
        AccountAPI accountAPI = lb.getRetrofit().create(AccountAPI.class);

        JsonObject call = accountAPI.SalesRegisterCardWise(jCheckBox1.isSelected()).execute().body();

        lb.addGlassPane(this);

        if (call != null) {
            JsonObject result = call;
            if (result.get("result").getAsInt() == 1) {
                JsonArray array = call.getAsJsonArray("data");
                dtm.setRowCount(0);
                double net = 0.00;
                for (int i = 0; i < array.size(); i++) {
                    try {
                        Vector row = new Vector();
                        row.add(i + 1);
                        row.add((array.get(i).getAsJsonObject().get("AC_CD").getAsString()));
                        row.add((array.get(i).getAsJsonObject().get("FNAME") == null) ? ""
                                : array.get(i).getAsJsonObject().get("FNAME").getAsString());
                        row.add((array.get(i).getAsJsonObject().get("CARD_NO").getAsString()));
                        row.add((array.get(i).getAsJsonObject().get("MOBILE1").getAsString()));
                        row.add(lb.Convert2DecFmtForRs(
                                array.get(i).getAsJsonObject().get("NET_AMT").getAsDouble()));
                        dtm.addRow(row);
                        net += array.get(i).getAsJsonObject().get("NET_AMT").getAsDouble();
                    } catch (Exception e) {

                    }
                }

                Vector row = new Vector();
                row.add(" ");
                row.add(" ");
                row.add(" ");
                row.add(" ");
                row.add(" ");
                row.add(" ");
                dtm.addRow(row);

                row = new Vector();
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add(lb.Convert2DecFmtForRs(net));
                dtm.addRow(row);

                lb.setColumnSizeForTable(jTable1, jPanel1.getWidth());
                lb.removeGlassPane(SalesRegisterCardWise.this);
            } else {
                lb.removeGlassPane(SalesRegisterCardWise.this);
                lb.showMessageDailog(call.get("Cause").getAsString());
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(SalesRegisterCardWise.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:account.SalesRegisterDetailCardWise.java

private void jbtnViewActionPerformedRoutine() {
    try {// www  .jav  a2  s .co m
        AccountAPI accountAPI = lb.getRetrofit().create(AccountAPI.class);

        if (ac_cd == null) {
            ac_cd = "";
        }
        if (!jCheckBox1.isSelected()) {
            ac_cd = "";
        }
        JsonObject call = accountAPI.CardWiseSalesDetailStatement(ac_cd).execute().body();

        lb.addGlassPane(this);

        if (call != null) {
            JsonObject result = call;
            if (result.get("result").getAsInt() == 1) {
                JsonArray array = call.getAsJsonArray("data");
                dtm.setRowCount(0);
                dtm.setRowCount(0);
                double basic_amt = 0.00, tax_amt = 0.00, net_amt = 0.00, buy_back_amt = 0.00, ins_amt = 0.00,
                        bajaj = 0.00;
                double cash = 0.00, bank = 0.00, card = 0.00;
                String tax_name = "";
                String buy_back_model = "";
                String old_ref_no = "";
                for (int i = 0; i < array.size(); i++) {
                    if (!old_ref_no.equalsIgnoreCase("") && !old_ref_no
                            .equalsIgnoreCase(array.get(i).getAsJsonObject().get("ref_no").getAsString())) {
                        Vector row = new Vector();
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add(basic_amt);
                        row.add(lb.Convert2DecFmtForRs(tax_amt));
                        row.add(net_amt);
                        row.add(tax_name);
                        row.add(cash);
                        row.add(bank);
                        row.add(card);
                        row.add(bajaj);
                        row.add(buy_back_amt);
                        row.add(buy_back_model);
                        row.add(ins_amt);
                        row.add(lb.Convert2DecFmtForRs(
                                basic_amt + tax_amt - cash - bank - card - buy_back_amt + ins_amt - bajaj));
                        basic_amt = 0.00;
                        dtm.addRow(row);
                    }
                    Vector row = new Vector();
                    row.add(array.get(i).getAsJsonObject().get("ref_no").getAsString());
                    if (basic_amt == 0.00) {
                        row.add(array.get(i).getAsJsonObject().get("v_type").getAsString());
                        row.add(array.get(i).getAsJsonObject().get("inv_no").getAsInt());
                        row.add(lb.ConvertDateFormetForDisplay(
                                array.get(i).getAsJsonObject().get("v_date").getAsString()));
                        row.add((array.get(i).getAsJsonObject().get("fname") == null) ? ""
                                : array.get(i).getAsJsonObject().get("fname").getAsString());
                    } else {
                        row.add("");
                        row.add("");
                        row.add("");
                        row.add("");
                    }
                    row.add(array.get(i).getAsJsonObject().get("SR_ALIAS").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("SR_NAME").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("IMEI_NO").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("SERAIL_NO").getAsString());
                    row.add(array.get(i).getAsJsonObject().get("QTY").getAsInt());
                    row.add(array.get(i).getAsJsonObject().get("RATE").getAsDouble());
                    row.add(array.get(i).getAsJsonObject().get("AMT").getAsDouble());
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    row.add("");
                    dtm.addRow(row);
                    basic_amt = array.get(i).getAsJsonObject().get("det_tot").getAsDouble();
                    tax_amt = array.get(i).getAsJsonObject().get("tax_amt").getAsDouble()
                            + array.get(i).getAsJsonObject().get("add_tax_amt").getAsDouble();
                    net_amt = array.get(i).getAsJsonObject().get("net_amt").getAsDouble();
                    cash = array.get(i).getAsJsonObject().get("CASH_AMT").getAsDouble();
                    bank = array.get(i).getAsJsonObject().get("BANK_AMT").getAsDouble();
                    card = array.get(i).getAsJsonObject().get("CARD_AMT").getAsDouble();
                    tax_name = array.get(i).getAsJsonObject().get("tax_name").getAsString();
                    buy_back_model = array.get(i).getAsJsonObject().get("buy_back_model").getAsString();
                    buy_back_amt = array.get(i).getAsJsonObject().get("buy_back_amt").getAsDouble();
                    ins_amt = array.get(i).getAsJsonObject().get("ins_amt").getAsDouble();
                    bajaj = array.get(i).getAsJsonObject().get("bajaj_amt").getAsDouble();
                    old_ref_no = array.get(i).getAsJsonObject().get("ref_no").getAsString();
                }
                Vector row = new Vector();
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add(basic_amt);
                row.add(lb.Convert2DecFmtForRs(tax_amt));
                row.add(net_amt);
                row.add(tax_name);
                row.add(cash);
                row.add(bank);
                row.add(card);
                row.add(bajaj);
                row.add(buy_back_amt);
                row.add(buy_back_model);
                row.add(ins_amt);
                row.add(lb.Convert2DecFmtForRs(
                        basic_amt + tax_amt + ins_amt - cash - bank - card - buy_back_amt - bajaj));
                basic_amt = 0.00;
                dtm.addRow(row);

                double tot_basic = 0.00, tot_tax = 0.00, tot_cash = 0.00, tot_bank = 0.00, tot_card = 0.00,
                        tot_buyBack = 0.00, tot_deb = 0.00, tot_ins_amt = 0.00, tot_bajaj_amt = 0.00,
                        tot_net_amt = 0.00;
                for (int i = 0; i < jTable1.getRowCount(); i++) {
                    tot_basic += lb.isNumber2(jTable1.getValueAt(i, 12).toString());
                    tot_tax += lb.isNumber2(jTable1.getValueAt(i, 13).toString());
                    tot_net_amt += lb.isNumber2(jTable1.getValueAt(i, 14).toString());
                    tot_cash += lb.isNumber2(jTable1.getValueAt(i, 16).toString());
                    tot_card += lb.isNumber2(jTable1.getValueAt(i, 18).toString());
                    tot_bajaj_amt += lb.isNumber2(jTable1.getValueAt(i, 19).toString());
                    tot_buyBack += lb.isNumber2(jTable1.getValueAt(i, 20).toString());
                    tot_ins_amt += lb.isNumber2(jTable1.getValueAt(i, 22).toString());
                    tot_deb += lb.isNumber2(jTable1.getValueAt(i, 23).toString());
                }
                row = new Vector();
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add("");
                row.add(lb.Convert2DecFmtForRs(tot_basic));
                row.add(lb.Convert2DecFmtForRs(tot_tax));
                row.add(lb.Convert2DecFmtForRs(tot_net_amt));
                row.add("");
                row.add(lb.Convert2DecFmtForRs(tot_cash));
                row.add(lb.Convert2DecFmtForRs(tot_bank));
                row.add(lb.Convert2DecFmtForRs(tot_card));
                row.add(lb.Convert2DecFmtForRs(tot_bajaj_amt));
                row.add(lb.Convert2DecFmtForRs(tot_buyBack));
                row.add("");
                row.add(lb.Convert2DecFmtForRs(tot_ins_amt));
                row.add(lb.Convert2DecFmtForRs(tot_deb));
                dtm.addRow(row);

                lb.setColumnSizeForTable(jTable1, jPanel1.getWidth());
                lb.removeGlassPane(SalesRegisterDetailCardWise.this);
            } else {
                lb.removeGlassPane(SalesRegisterDetailCardWise.this);
                lb.showMessageDailog(call.get("Cause").getAsString());
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(SalesRegisterDetailCardWise.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:account.SalesRegisterDetailCardWise.java

private void jtxtCardNoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtxtCardNoKeyPressed
    // TODO add your handling code here:

    if (lb.isEnter(evt) && !lb.isBlank(jtxtCardNo)) {
        try {//from www.j av  a2 s  . c  om
            lb.addGlassPane(this);
            JsonObject call = lb.getRetrofit().create(SalesAPI.class)
                    .GetDataFromServer(jtxtCardNo.getText(), "22").execute().body();
            lb.removeGlassPane(SalesRegisterDetailCardWise.this);
            if (call != null) {
                JsonArray array = call.getAsJsonArray("data");
                if (array.size() > 0) {
                    ac_cd = (array.get(0).getAsJsonObject().get("AC_CD").getAsString());
                    jtxtAcAlias.setText(ac_cd);
                    jtxtAcName.setText(array.get(0).getAsJsonObject().get("FNAME").getAsString());
                    jtxtCardNo.setText(array.get(0).getAsJsonObject().get("CARD_NO").getAsString());
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(SalesRegisterDetailCardWise.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}