javax.swing.JTable.hasFocus()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(2.2k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中javax.swing.JTable.hasFocus()方法的一些代码示例,展示了JTable.hasFocus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.hasFocus()方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:hasFocus

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);

相关文章

JTable类方法