本文整理了Java中javax.swing.JTable.hasFocus()
方法的一些代码示例,展示了JTable.hasFocus()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.hasFocus()
方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:hasFocus
暂无
代码示例来源:origin: cpesch/RouteConverter
private void ensureSelection(MouseEvent e, int selectedRowCountMinimum) {
if (!table.hasFocus())
table.requestFocus();
if (table.getSelectedRowCount() < selectedRowCountMinimum) {
// dispatch event again as a left mouse click for selections
// (do not try to spare one of the three events)
table.dispatchEvent(new MouseEvent((Component) e.getSource(), MOUSE_PRESSED, e.getWhen(),
BUTTON1_MASK, e.getX(), e.getY(),
e.getClickCount(), false));
table.dispatchEvent(new MouseEvent((Component) e.getSource(), MOUSE_RELEASED, e.getWhen(),
BUTTON1_MASK, e.getX(), e.getY(),
e.getClickCount(), false));
table.dispatchEvent(new MouseEvent((Component) e.getSource(), MOUSE_CLICKED, e.getWhen(),
BUTTON1_MASK, e.getX(), e.getY(),
e.getClickCount(), false));
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
public void actionPerformed(ActionEvent e)
{
JTable table=(JTable)e.getSource();
if(!table.hasFocus())
{
CellEditor cellEditor=table.getCellEditor();
if(cellEditor!=null && !cellEditor.stopCellEditing())
{
return;
}
table.requestFocus();
return;
}
ListSelectionModel rsm=table.getSelectionModel();
int anchorRow=rsm.getAnchorSelectionIndex();
ListSelectionModel csm=table.getColumnModel().getSelectionModel();
int anchorColumn=csm.getAnchorSelectionIndex();
table.editCellAt(anchorRow, anchorColumn);
Component editorComp=table.getEditorComponent();
if(editorComp!=null)
{
editorComp.requestFocus();
}
}
}
代码示例来源:origin: mucommander/mucommander
if(!table.hasFocus())
matches = true;
else {
focusedIndex = table.hasFocus() ? ThemeCache.ACTIVE : ThemeCache.INACTIVE;
colorIndex = getColorIndex(rowIndex, file, tableModel);
label.setBackground(ThemeCache.backgroundColors[focusedIndex][ThemeCache.SELECTED], ThemeCache.backgroundColors[focusedIndex][ThemeCache.SECONDARY]);
else if(matches) {
if(table.hasFocus() && search.isActive())
label.setBackground(ThemeCache.backgroundColors[focusedIndex][ThemeCache.NORMAL]);
else
label.setOutline(table.hasFocus() ? ThemeCache.activeOutlineColor : ThemeCache.inactiveOutlineColor);
else
label.setOutline(null);
内容来源于网络,如有侵权,请联系作者删除!