Java examples for Swing:JTable Model
This method returns a JTable with the given model.
//package com.java2s; import java.awt.Color; import javax.swing.JTable; import javax.swing.table.TableModel; public class Main { /**This method returns a table with the given model. * The table will be not editable and only row selection will be allowed. */ public static JTable constructTable(TableModel model) { JTable table = new JTable() { private static final long serialVersionUID = -5079355133615100914L; @Override// w ww .j av a 2s . c o m public boolean isCellEditable(int x, int y) { return false; } }; table.setModel(model); table.setColumnSelectionAllowed(false); table.setRowSelectionAllowed(true); table.setSelectionForeground(Color.BLUE); return table; } }