package devopsdistilled.operp.client.items.panes;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;

import javax.inject.Inject;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;

import net.miginfocom.swing.MigLayout;
import devopsdistilled.operp.client.abstracts.SubTaskPane;
import devopsdistilled.operp.client.abstracts.libs.BeanTableModel;
import devopsdistilled.operp.client.items.models.observers.CategoryModelObserver;
import devopsdistilled.operp.client.items.panes.details.CategoryDetailsPane;
import devopsdistilled.operp.client.items.panes.models.observers.ListCategoryPaneModelObserver;
import devopsdistilled.operp.server.data.entity.items.Category;

public class ListCategoryPane extends SubTaskPane implements
		ListCategoryPaneModelObserver, CategoryModelObserver {

	@Inject
	private CategoryDetailsPane categoryDetailsPane;

	private final JPanel pane;

	private final JTable table;
	BeanTableModel<Category> tableModel;

	public ListCategoryPane() {
		pane = new JPanel(new MigLayout("debug, fill"));

		tableModel = new BeanTableModel<>(Category.class);
		table = new JTable(tableModel);
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

		table.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				if (SwingUtilities.isLeftMouseButton(e)
						&& e.getClickCount() == 2
						&& table.getSelectedRow() != -1) {

					Category category = tableModel.getRow(table
							.getSelectedRow());

					categoryDetailsPane.show(category);
				}
			}
		});

		final JScrollPane scrollPane = new JScrollPane(table,
				JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

		pane.add(scrollPane, "grow");
	}

	@Override
	public JComponent getPane() {
		return pane;
	}

	@Override
	public void updateCategories(List<Category> categories) {
		if (tableModel.getRowCount() != 0) {
			int lastRow = tableModel.getRowCount() - 1;
			tableModel.removeRowRange(0, lastRow);
		}

		tableModel.insertRows(0, categories);
	}
}

package devopsdistilled.operp.client.items.panes;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;

import javax.inject.Inject;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;

import net.miginfocom.swing.MigLayout;
import devopsdistilled.operp.client.abstracts.SubTaskPane;
import devopsdistilled.operp.client.abstracts.libs.BeanTableModel;
import devopsdistilled.operp.client.items.models.observers.CategoryModelObserver;
import devopsdistilled.operp.client.items.panes.details.CategoryDetailsPane;
import devopsdistilled.operp.client.items.panes.models.observers.ListCategoryPaneModelObserver;
import devopsdistilled.operp.server.data.entity.items.Category;

public class ListCategoryPane extends SubTaskPane implements
		ListCategoryPaneModelObserver, CategoryModelObserver {

	@Inject
	private CategoryDetailsPane categoryDetailsPane;

	private final JPanel pane;

	private final JTable table;
	BeanTableModel<Category> tableModel;

	public ListCategoryPane() {
		pane = new JPanel(new MigLayout("debug, fill"));

		tableModel = new BeanTableModel<>(Category.class);
		table = new JTable(tableModel);
		tableModel.setModelEditable(false);
		table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		table.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				if (SwingUtilities.isLeftMouseButton(e)
						&& e.getClickCount() == 2
						&& table.getSelectedRow() != -1) {

					Category category = tableModel.getRow(table
							.getSelectedRow());

					categoryDetailsPane.show(category);
				}
			}
		});

		final JScrollPane scrollPane = new JScrollPane(table,
				JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
				JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

		pane.add(scrollPane, "grow");
	}

	@Override
	public JComponent getPane() {
		return pane;
	}

	@Override
	public void updateCategories(List<Category> categories) {
		if (tableModel.getRowCount() != 0) {
			int lastRow = tableModel.getRowCount() - 1;
			tableModel.removeRowRange(0, lastRow);
		}

		tableModel.insertRows(0, categories);
	}
}

Add tableModel.setModelEditable(false);