当前位置: 首页>>代码示例>>Java>>正文


Java JTable.requestFocus方法代码示例

本文整理汇总了Java中javax.swing.JTable.requestFocus方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.requestFocus方法的具体用法?Java JTable.requestFocus怎么用?Java JTable.requestFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.requestFocus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: actionPerformed

import javax.swing.JTable; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent ae) {
    JTable jt = (JTable) ae.getSource();
    int row = jt.getSelectedRow();
    int col = jt.getSelectedColumn();

    if ((row != -1) && (col != -1)) {
        if (PropUtils.isLoggable(BaseTable.class)) {
            PropUtils.log(BaseTable.class, "Starting edit due to key event for row " + row); //NOI18N
        }

        jt.editCellAt(row, 1, null);

        //Focus will be rerouted to the editor via this call:
        jt.requestFocus();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:BaseTable.java

示例2: mouseClicked

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
        if (!(e.getSource() instanceof JTable)) {
            return;
        }

        tableComponent = (JTable) e.getSource();
        tableComponent.requestFocus();

        int nx = e.getX();

        if (nx > 500) {
            nx = nx - popup.getSize().width;
        }
        popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
    }
}
 
开发者ID:RipMeApp,项目名称:ripme,代码行数:19,代码来源:HistoryMenuMouseListener.java

示例3: stopCellEditing

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public boolean stopCellEditing() {
    String s = cell.toString();
    Window ancestorWindow = (Window)SwingUtilities.getRoot(cell);
    // #236458: options are now saved asynchronously. If the dialog was to 
    if (ancestorWindow == null) {
        return true;
    }
    // HACK: if this Editor creates a dialog, it will lose the focus and Swing
    // will remove the editor, calling JTable.cancelEditing. Any re-selections performed
    // by the JTable will occur BEFORE the dialog is finished, so we need to
    // reestablish the column selection later from here.
    // This binds the BCEditor to the KeymapTable layout / internals.
    JTable parent = (JTable)cell.getParent();
    
    ShortcutAction sca = (ShortcutAction) action;
    Set<ShortcutAction> conflictingAction = model.getMutableModel().findActionForShortcutPrefix(s);
    conflictingAction.remove(sca); //remove the original action
    
    Collection<ShortcutAction> sameScopeActions = model.getMutableModel().filterSameScope(conflictingAction, sca);
    
    if (!conflictingAction.isEmpty()) {
         if (!SwingUtilities.isEventDispatchThread()) {
             // #236458: options are now saved asynchronously, off EDT. If we display dialog, the IDE will lock up.
            cell.getTextField().setText(orig);
            fireEditingCanceled();
            return true;
         }
        //there is a conflicting action, show err dialog
        Object overrride = overrride(conflictingAction, sameScopeActions);
        
        // bring the focus back
        ancestorWindow.toFront();
        parent.requestFocus();
        if (overrride.equals(DialogDescriptor.YES_OPTION)) {
            for (ShortcutAction sa : conflictingAction) {
                removeConflictingShortcut(sa, s); //remove all conflicting shortcuts
            }
            //proceed with override
        } else if (overrride == DialogDescriptor.CANCEL_OPTION) {
            cell.getTextField().setText(orig);
            fireEditingCanceled();
            setBorderEmpty();
            return true;
        }
        // NO_OPTION fallls through and adds additional shortcut.
    }
    cell.getTextField().removeActionListener(delegate);
    cell.getTextField().removeKeyListener(escapeAdapter);
    model.getMutableModel().removeShortcut((ShortcutAction) action, orig);
    if (!(s.length() == 0)) // do not add empty shortcuts
        model.getMutableModel().addShortcut((ShortcutAction) action, s);
    fireEditingStopped();
    setBorderEmpty();
    model.update();
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:58,代码来源:ButtonCellEditor.java


注:本文中的javax.swing.JTable.requestFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。