Java JTable Model toTableModel(HashMap data)

Here you can find the source of toTableModel(HashMap data)

Description

to Table Model

License

Open Source License

Declaration

public static DefaultTableModel toTableModel(HashMap data) 

Method Source Code

//package com.java2s;
/*/*  ww w  .jav  a  2 s  .co  m*/
 * 
This file is part of YaBS.
    
YaBS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
YaBS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with YaBS.  If not, see <http://www.gnu.org/licenses/>.
    
 * 
 */

import java.util.HashMap;

import javax.swing.table.DefaultTableModel;

public class Main {
    public static DefaultTableModel toTableModel(HashMap data) {

        Object[] array = data.keySet().toArray();
        Object[][] table = new Object[array.length][1];

        for (int i = 0; i < array.length; i++) {
            table[i][0] = array[i];
        }

        return new DefaultTableModel(table, new Object[] { "Devices" });
    }
}

Related

  1. saveTModelToCSV(String fileName, JTable table)
  2. setDataVector(DefaultTableModel model, Vector dataVector)
  3. tableModelToArray(JTable table)
  4. TableModelToList(JTable mode)
  5. toCsv(TableModel model)