本文整理汇总了Java中java.awt.event.FocusEvent类的典型用法代码示例。如果您正苦于以下问题:Java FocusEvent类的具体用法?Java FocusEvent怎么用?Java FocusEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FocusEvent类属于java.awt.event包,在下文中一共展示了FocusEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EditorUI
import java.awt.event.FocusEvent; //导入依赖的package包/类
/** Construct extended UI for the use with a text component */
public EditorUI() {
focusL = new FocusAdapter() {
public @Override void focusGained(FocusEvent evt) {
/* Fix of #25475 - copyAction's enabled flag
* must be updated on focus change
*/
stateChanged(null);
if (component!=null){
BaseTextUI ui = (BaseTextUI)component.getUI();
if (ui!=null) ui.refresh();
}
}
@Override
public void focusLost(FocusEvent e) {
// see #222935, update actions before menu activates
if (e.isTemporary()) {
doStateChange(true);
}
}
};
getToolTipSupport();
}
示例2: SpecialkeyPanel
import java.awt.event.FocusEvent; //导入依赖的package包/类
/** Creates new form SpecialkeyPanel */
public SpecialkeyPanel(final Popupable parent, JTextField target) {
this.parent = parent;
this.target = target;
initComponents();
target.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
parent.hidePopup();
}
});
downButton.addActionListener(this);
enterButton.addActionListener(this);
escButton.addActionListener(this);
leftButton.addActionListener(this);
rightButton.addActionListener(this);
tabButton.addActionListener(this);
upButton.addActionListener(this);
wheelUpButton.addActionListener(this);
wheelDownButton.addActionListener(this);
}
示例3: handleJavaMouseEvent
import java.awt.event.FocusEvent; //导入依赖的package包/类
void handleJavaMouseEvent(MouseEvent e) {
switch (e.getID()) {
case MouseEvent.MOUSE_PRESSED:
if (target == e.getSource() &&
!target.isFocusOwner() &&
XKeyboardFocusManagerPeer.shouldFocusOnClick(target))
{
XWindowPeer parentXWindow = getParentTopLevel();
Window parentWindow = ((Window)parentXWindow.getTarget());
// Simple windows are non-focusable in X terms but focusable in Java terms.
// As X-non-focusable they don't receive any focus events - we should generate them
// by ourselfves.
// if (parentXWindow.isFocusableWindow() /*&& parentXWindow.isSimpleWindow()*/ &&
// !(getCurrentNativeFocusedWindow() == parentWindow))
// {
// setCurrentNativeFocusedWindow(parentWindow);
// WindowEvent wfg = new WindowEvent(parentWindow, WindowEvent.WINDOW_GAINED_FOCUS);
// parentWindow.dispatchEvent(wfg);
// }
XKeyboardFocusManagerPeer.requestFocusFor(target, FocusEvent.Cause.MOUSE_EVENT);
}
break;
}
}
示例4: focusGained
import java.awt.event.FocusEvent; //导入依赖的package包/类
public @Override void focusGained(FocusEvent evt) {
if (LOG.isLoggable(Level.FINE)) {
LOG.fine(
"BaseCaret.focusGained(); doc=" + // NOI18N
component.getDocument().getProperty(Document.TitleProperty) + '\n'
);
}
JTextComponent c = component;
if (c != null) {
updateType();
if (component.isEnabled()) {
if (component.isEditable()) {
setVisible(true);
}
setSelectionVisible(true);
}
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("Caret visibility: " + isVisible() + '\n'); // NOI18N
}
} else {
if (LOG.isLoggable(Level.FINER)) {
LOG.finer("Text component is null, caret will not be visible" + '\n'); // NOI18N
}
}
}
示例5: focusLost
import java.awt.event.FocusEvent; //导入依赖的package包/类
/** Delegates to the original listener.
*/
@Override public void focusLost(FocusEvent ev) {
FocusListener l = (FocusListener) super.get(ev);
if (l != null) {
l.focusLost(ev);
}
}
示例6: run
import java.awt.event.FocusEvent; //导入依赖的package包/类
@Override
public Object run() {
switch (type) {
case 0:
guardedPaint((Graphics) p1);
break;
case 1:
guardedValidateTree();
break;
case 2:
guardedDoLayout();
break;
case 3:
ExplorerTree.super.processFocusEvent((FocusEvent)p1);
//Since the selected when focused is different, we need to force a
//repaint of the entire selection, but let's do it in guarded more
//as any other repaint
repaintSelection();
break;
default:
throw new IllegalStateException("type: " + type);
}
return null;
}
示例7: doRestoreFocus
import java.awt.event.FocusEvent; //导入依赖的package包/类
private boolean doRestoreFocus(Component toFocus, Component vetoedComponent,
boolean clearOnFailure)
{
if (toFocus != vetoedComponent && toFocus.isShowing() && toFocus.canBeFocusOwner() &&
toFocus.requestFocus(false, FocusEvent.Cause.ROLLBACK))
{
return true;
} else {
Component nextFocus = toFocus.getNextFocusCandidate();
if (nextFocus != null && nextFocus != vetoedComponent &&
nextFocus.requestFocusInWindow(FocusEvent.Cause.ROLLBACK))
{
return true;
} else if (clearOnFailure) {
clearGlobalFocusOwnerPriv();
return true;
} else {
return false;
}
}
}
示例8: focusLost
import java.awt.event.FocusEvent; //导入依赖的package包/类
@Override
public void focusLost(FocusEvent e) {
Component c = e.getOppositeComponent();
if (c != searchCombo) {
removeSearchField();
}
}
示例9: focusGained
import java.awt.event.FocusEvent; //导入依赖的package包/类
/******** implementation of focus listener, for slow click rename cancelling ******/
@Override
public void focusGained(FocusEvent e) {
// don't allow to invoke click to rename immediatelly after focus gain
// what may happen is that tree gains focus by mouse
// click on selected item - on some platforms selected item
// is not visible without focus and click to rename will
// be unwanted and surprising for users
// see run method
SwingUtilities.invokeLater(this);
}
示例10: trackEvent
import java.awt.event.FocusEvent; //导入依赖的package包/类
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) {
EventListener listener = null;
switch (eventID) {
case WindowEvent.WINDOW_GAINED_FOCUS:
listener = wgfListener;
break;
case FocusEvent.FOCUS_GAINED:
listener = fgListener;
break;
case ActionEvent.ACTION_PERFORMED:
listener = apListener;
break;
}
listener.listen(comp, printEvent);
action.run();
return Util.waitForCondition(listener.getNotifier(), time);
}
示例11: tfClassToTestFocusLost
import java.awt.event.FocusEvent; //导入依赖的package包/类
/**
*/
private void tfClassToTestFocusLost(FocusEvent e) {
final Component allowFocusGain = focusGainAllowedFor;
focusGainAllowedFor = null;
if (multipleSourceRoots
&& interactionRestrictionsActive
&& !interactionRestrictionsSuspended) {
final Component opposite = e.getOppositeComponent();
if ((allowFocusGain != null) && (opposite == allowFocusGain)) {
return;
}
if (opposite == btnBrowse) {
return;
}
if ((opposite instanceof JLabel)
&& (((JLabel) opposite).getLabelFor() == tfClassToTest)) {
/*
* When a JLabel's mnemonic key is pressed, the JLabel gains focus
* until the key is released again. That's why we must ignore such
* focus transfers.
*/
return;
}
if (!maybeDisplaySourceGroupChooser()) {
/* send the request back to the Test to Class textfield: */
tfClassToTest.requestFocus();
}
}
}
示例12: init
import java.awt.event.FocusEvent; //导入依赖的package包/类
/**
* Configurar os componentes da janela
*/
public final void init() {
setLayout(new AbsoluteLayout());
setUndecorated(true);
setBackground(new Color(0, 0, 0, 0));
add(new JLabel(imagem), new AbsoluteConstraints(0, 0));
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
dispose();
}
});
}
示例13: CCCreateAnswerPlaceholderPanel
import java.awt.event.FocusEvent; //导入依赖的package包/类
public CCCreateAnswerPlaceholderPanel(@Nullable String placeholderText, @NotNull List<String> hints) {
if (hints.isEmpty()) {
myHints.add(HINT_PLACEHOLDER);
}
else {
myHints.addAll(hints);
}
myPlaceholderTextArea.setBorder(BorderFactory.createLineBorder(JBColor.border()));
myPlaceholderTextArea.setText(placeholderText);
myPlaceholderTextArea.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
myPlaceholderTextArea.selectAll();
}
});
myPlaceholderTextArea.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
myPlaceholderTextArea.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
myHintsPanel.setBorder(BorderFactory.createLineBorder(JBColor.border()));
((GridLayoutManager)myHintsPanel.getLayout()).setHGap(1);
myHintTextArea.setFont(UIUtil.getLabelFont());
myPlaceholderTextArea.setFont(UIUtil.getLabelFont());
myHintTextArea.addFocusListener(createFocusListenerToSetDefaultHintText());
actionsPanel.add(createHintToolbarComponent(), BorderLayout.WEST);
showHint();
}
示例14: focusGained
import java.awt.event.FocusEvent; //导入依赖的package包/类
@Override
public void focusGained(FocusEvent e) {
/*
* Order of method calls hideInfo() and super.focusGained(e) is
* important! See bug #113202.
*/
if (infoDisplayed) {
hideInfo();
}
super.focusGained(e); //selects all text
}
示例15: focusLost
import java.awt.event.FocusEvent; //导入依赖的package包/类
public void focusLost(FocusEvent e) {
Object source = e.getSource();
if (source == windowsSwanExeTextField) {
//if windowsSwanExeTextField lost focus.
updateSwanExecutableFromTextField();
}
}