本文整理了Java中java.awt.Window.getMostRecentFocusOwner()
方法的一些代码示例,展示了Window.getMostRecentFocusOwner()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getMostRecentFocusOwner()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:getMostRecentFocusOwner
[英]Returns the child Component of this Window that will receive the focus when this Window is focused. If this Window is currently focused, this method returns the same Component as getFocusOwner()
. If this Window is not focused, then the child Component that most recently requested focus will be returned. If no child Component has ever requested focus, and this is a focusable Window, then this Window's initial focusable Component is returned. If no child Component has ever requested focus, and this is a non-focusable Window, null is returned.
[中]返回此窗口的子组件,该组件将在该窗口聚焦时接收焦点。如果此窗口当前处于聚焦状态,则此方法返回与getFocusOwner()
相同的组件。如果此窗口未聚焦,则将返回最近请求聚焦的子组件。如果没有子组件请求过焦点,并且这是一个可聚焦窗口,则返回该窗口的初始可聚焦组件。如果没有子组件请求过焦点,并且这是一个不可聚焦的窗口,则返回null。
代码示例来源:origin: freeplane/freeplane
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Object value = getValueAt(row, column);
boolean isSelected = false;
boolean hasFocus = false;
// Only indicate the selection and focused cell if not printing
MapView map = (MapView) SwingUtilities.getAncestorOfClass(MapView.class, this);
if (map == null || ! map.isPrinting()) {
isSelected = isCellSelected(row, column);
boolean rowIsLead =
(selectionModel.getLeadSelectionIndex() == row);
boolean colIsLead =
(columnModel.getSelectionModel().getLeadSelectionIndex() == column);
final Window windowAncestor = SwingUtilities.getWindowAncestor(this);
hasFocus = (rowIsLead && colIsLead) && windowAncestor != null && equals(windowAncestor.getMostRecentFocusOwner());
}
return renderer.getTableCellRendererComponent(this, value,
isSelected, hasFocus,
row, column);
}
代码示例来源:origin: stackoverflow.com
JOptionPane.showMessageDialog(null, getMostRecentFocusOwner().getName());
代码示例来源:origin: freeplane/freeplane
parentWindow = SwingUtilities.getWindowAncestor(appendButton);
final Component mostRecentFocusOwner = parentWindow.getMostRecentFocusOwner();
if (mostRecentFocusOwner instanceof JTextComponent
&& !(mostRecentFocusOwner.getClass().getName().contains("JSpinField"))) {
代码示例来源:origin: freeplane/freeplane
private Container getContentPane() {
if (contentPane == null) {
Window windowAncestor = SwingUtilities.getWindowAncestor(mainView);
boolean hasFocus = windowAncestor != null && windowAncestor.getMostRecentFocusOwner() == mainView;
contentPane = NodeViewFactory.getInstance().newContentPane(this);
final int index = getComponentCount() - 1;
remove(index);
contentPane.add(mainView);
mainView.putClientProperty("NODE_VIEW_CONTENT_POSITION", MAIN_VIEWER_POSITION);
if(! mainView.isVisible())
mainView.setVisible(true);
add(contentPane, index);
if(hasFocus)
restoreFocusToMainView();
}
return contentPane;
}
代码示例来源:origin: omegat-org/omegat
@Override
public void windowGainedFocus(WindowEvent e) {
Window w = e.getOppositeWindow();
if (w != null) {
String sel = getSelectedText(w.getMostRecentFocusOwner());
if (!StringUtil.isEmpty(sel)) {
if (StringUtil.isEmpty(dialog.getSourceText().getText())) {
setText(dialog.getSourceText(), sel);
} else if (StringUtil.isEmpty(dialog.getTargetText().getText())) {
setText(dialog.getTargetText(), sel);
} else if (StringUtil.isEmpty(dialog.getCommentText().getText())) {
setText(dialog.getCommentText(), sel);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!