Load arrayList data into JTable

后端 未结 4 517
无人及你
无人及你 2020-11-29 05:16

I\'m trying to set items from a method called FootballClub and so far it\'s fine. but then I created an arrayList from it and I somehow can\'t find a way to sto

4条回答
  •  星月不相逢
    2020-11-29 05:57

    You can do something like what i did with my List< Future< String > > or any other Arraylist, Type returned from other class called PingScan that returns List> because it implements service executor. Anyway the code down note that you can use foreach and retrieve data from the List.

     PingScan p = new PingScan();
     List> scanResult = p.checkThisIP(jFormattedTextField1.getText(), jFormattedTextField2.getText());
                    for (final Future f : scanResult) {
                        try {
                            if (f.get() instanceof String) {
                                String ip = f.get();
                                Object[] data = {ip};
                                tableModel.addRow(data);
                            }
                        } catch (InterruptedException | ExecutionException ex) {
                            Logger.getLogger(gui.class.getName()).log(Level.SEVERE, null, ex);
                        }
                    }
    

提交回复
热议问题