001package jmri.jmrit.beantable; 002 003import java.awt.event.KeyEvent; 004 005import jmri.NamedBean; 006 007/** 008 * JTable for displaying a BeanTableDataModel. 009 * Code originally within BeanTableDataModel. 010 * @author Bob Jacobsen Copyright (C) 2003, 2004, 2007 011 * @author Egbert Broerse Copyright (C) 2017 012 * @author Steve Young Copyright (C) 2021, 2024 013 * @param <T> Bean type, e.g. Sensor or Turnout. 014 */ 015public class BeanTableJTable<T extends NamedBean> extends javax.swing.JTable { 016 017 private final BeanTableDataModel<T> model; 018 019 public BeanTableJTable(BeanTableDataModel<T> beanTableModel) { 020 super(beanTableModel); 021 model = beanTableModel; 022 } 023 024 @Override 025 public String getToolTipText(java.awt.event.MouseEvent e) { 026 java.awt.Point p = e.getPoint(); 027 int modelRowIndex = convertRowIndexToModel(rowAtPoint(p)); 028 int modelColumnIndex = convertColumnIndexToModel(columnAtPoint(p)); 029 return model.getCellToolTip(this, modelRowIndex, modelColumnIndex); 030 } 031 032 /** 033 * Disable Windows Key or Mac Meta Keys being pressed acting 034 * as a trigger for editing the focused cell. 035 * Causes unexpected behaviour, i.e. button presses. 036 * {@inheritDoc} 037 */ 038 @Override 039 public boolean editCellAt(int row, int column, java.util.EventObject e) { 040 if ( (e instanceof KeyEvent) && 041 ( ((KeyEvent) e).getKeyCode() == KeyEvent.VK_WINDOWS || 042 ( (KeyEvent) e).getKeyCode() == KeyEvent.VK_META )){ 043 return false; 044 } 045 return super.editCellAt(row, column, e); 046 } 047 048}