简体   繁体   中英

C# DataTable XML Equivalent in java

    public Dictionary<string, SomeObject> DictionaryVar= new Dictionary<string, SomeObject>();

    foreach (SomeObject ojv in DictionaryVar.Values)
    {
        if (dt.Rows.Find(obj.FirstName()) == null)
        {
            dt.Rows.Add(new object[] { false, obj.FirstName(), "", "", 0 });
        }
    }

I have tried this but its not working.. I am trying to populate jtable by looping through some objects by checking whether the field exists if it doesn't , then i add it to the table.

for (SomeObject bs : DictionaryVar.values()) {
    System.out.println("not getting inside");
    for (int i = 0; i < jTable1.getRowCount(); i++) {
        if (!jTable1.getValueAt(i, 1).equals(bs.FirstName())) {
            ((DefaultTableModel) jTable1.getModel()).addRow(new Object[]{false, bs.FirstName(), "", "", 0, ""});
        } else {
        }
    }

}
System.out.println("the program is outputing this");
if (ListBookMark.size() > 0) {
    for (SomeObject bs : DictionaryVar.values()) {
        System.out.println("working now");
        if (jTable1.getModel().getColumnName(1).equalsIgnoreCase(bs.GetName()) == false) {
            ((DefaultTableModel) jTable1.getModel()).addRow(new Object[]{false, bs.GetName(), "", "", 0, ""});
        }

    }
}else {
 System.out.println("bs size = " +  (ListBookMark.size() ));
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM