本文整理匯總了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();
}
}
示例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);
}
}
示例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;
}