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


Java FocusEvent.getComponent方法代码示例

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


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

示例1: retargetUnexpectedFocusEvent

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new CausedFocusEvent(source, fe.getID(), temporary, opposite,
                                    CausedFocusEvent.Cause.NATIVE_SYSTEM);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:KeyboardFocusManager.java

示例2: retargetUnexpectedFocusEvent

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
static FocusEvent retargetUnexpectedFocusEvent(FocusEvent fe) {
    synchronized (heavyweightRequests) {
        // Any other case represents a failure condition which we did
        // not expect. We need to clearFocusRequestList() and patch up
        // the event as best as possible.

        if (removeFirstRequest()) {
            return (FocusEvent)retargetFocusEvent(fe);
        }

        Component source = fe.getComponent();
        Component opposite = fe.getOppositeComponent();
        boolean temporary = false;
        if (fe.getID() == FocusEvent.FOCUS_LOST &&
            (opposite == null || isTemporary(opposite, source)))
        {
            temporary = true;
        }
        return new FocusEvent(source, fe.getID(), temporary, opposite,
                                    FocusEvent.Cause.UNEXPECTED);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:KeyboardFocusManager.java

示例3: focusGained

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
public void focusGained(FocusEvent fe) {
    Component c = fe.getOppositeComponent();

    /*
    //handy for debugging
    System.out.println("Focus gained to " + (fe.getComponent().getName() == null ? fe.getComponent().getClass().getName() : fe.getComponent().getName()) + " temporary: " + fe.isTemporary()
    + " from " + (fe.getOppositeComponent() == null ? "null" :
        (fe.getOppositeComponent().getName() == null ? fe.getOppositeComponent().getClass().getName() : fe.getOppositeComponent().getName()))
    );
     */
    PropUtils.log(BaseTable.class, fe);

    if (!isKnownComponent(c)) {
        fireChange();
    }

    if (!inEditRequest() && !inEditorRemoveRequest() && (fe.getComponent() == this)) {
        //            System.out.println("Painting due to focus gain " + fe.getComponent());
        //            repaint(0,0,getWidth(),getHeight());
        paintSelectionRow();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:BaseTable.java

示例4: initComponentsMore

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
private void initComponentsMore() {
    contentPanel.setLayout(new GridBagLayout());
    contentPanel.setBackground(UIManager.getColor("Table.background")); //NOI18N
    
    int row = 0;
    combos = new ArrayList<>(items.size());

    Font monoSpaced = new Font("Monospaced", Font.PLAIN, new JLabel().getFont().getSize()); //NOI18N
    FocusListener focusListener = new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            Component c = e.getComponent();
            Rectangle r = c.getBounds();
            contentPanel.scrollRectToVisible(r);
        }

    };
    for (int i = 0; i < items.size(); i++) {
        ResolveDeclarationItem item = items.get(i);
        JComboBox jComboBox = createComboBox(item, monoSpaced, focusListener);
        combos.add(jComboBox);

        JLabel lblSimpleName = new JLabel(item.getName());
        lblSimpleName.setOpaque(false);
        lblSimpleName.setFont(monoSpaced);
        lblSimpleName.setLabelFor(jComboBox);

        contentPanel.add(lblSimpleName, new GridBagConstraints(0, row, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 2, 5), 0, 0));
        contentPanel.add(jComboBox, new GridBagConstraints(1, row++, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(3, 5, 2, 5), 0, 0));
    }

    contentPanel.add(new JLabel(), new GridBagConstraints(2, row, 2, 1, 0.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    Dimension d = contentPanel.getPreferredSize();
    d.height = getRowHeight() * Math.min(combos.size(), 6);

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ResolveDeclarationsPanel.java

示例5: focusGained

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e) {
    final Component c = e.getComponent();
    if (c instanceof JComponent) {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                RepoSelectorPanel.this.scrollRectToVisible(c.getBounds());
            }
        });
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:RepoSelectorPanel.java

示例6: focusLost

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
public void focusLost(FocusEvent event) {
  if (event.getComponent() instanceof JTable) {
    JTable table = (JTable) event.getComponent();
    if (table.isEditing()) {
      table.getCellEditor().stopCellEditing();
    }
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:9,代码来源:PropertySheet.java

示例7: focusLost

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
@Override
public void focusLost(FocusEvent e) {
	JTextField tf = (JTextField)e.getComponent();
	tf.select(0,0);
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:6,代码来源:TimeEntry.java

示例8: retargetFocusEvent

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
static AWTEvent retargetFocusEvent(AWTEvent event) {
    if (clearingCurrentLightweightRequests) {
        return event;
    }

    KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
    if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
        if (event instanceof FocusEvent || event instanceof WindowEvent) {
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
        if (focusLog.isLoggable(PlatformLogger.Level.FINER) && event instanceof KeyEvent) {
            focusLog.finer("    focus owner is {0}",
                           String.valueOf(manager.getGlobalFocusOwner()));
            focusLog.finer(">>> {0}", String.valueOf(event));
        }
    }

    synchronized(heavyweightRequests) {
        /*
         * This code handles FOCUS_LOST event which is generated by
         * DefaultKeyboardFocusManager for FOCUS_GAINED.
         *
         * This code based on knowledge of DefaultKeyboardFocusManager's
         * implementation and might be not applicable for another
         * KeyboardFocusManager.
         *
         * Fix for 4472032
         */
        if (newFocusOwner != null &&
            event.getID() == FocusEvent.FOCUS_LOST)
        {
            FocusEvent fe = (FocusEvent)event;

            if (manager.getGlobalFocusOwner() == fe.getComponent() &&
                fe.getOppositeComponent() == newFocusOwner)
            {
                newFocusOwner = null;
                return event;
            }
        }
    }

    processCurrentLightweightRequests();

    switch (event.getID()) {
        case FocusEvent.FOCUS_GAINED: {
            event = retargetFocusGained((FocusEvent)event);
            break;
        }
        case FocusEvent.FOCUS_LOST: {
            event = retargetFocusLost((FocusEvent)event);
            break;
        }
        default:
            /* do nothing */
    }
    return event;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:59,代码来源:KeyboardFocusManager.java

示例9: restoreFocus

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
private void restoreFocus(FocusEvent fe, Window newFocusedWindow) {
    Component realOppositeComponent = this.realOppositeComponentWR.get();
    Component vetoedComponent = fe.getComponent();

    if (newFocusedWindow != null && restoreFocus(newFocusedWindow,
                                                 vetoedComponent, false))
    {
    } else if (realOppositeComponent != null &&
               doRestoreFocus(realOppositeComponent, vetoedComponent, false)) {
    } else if (fe.getOppositeComponent() != null &&
               doRestoreFocus(fe.getOppositeComponent(), vetoedComponent, false)) {
    } else {
        clearGlobalFocusOwnerPriv();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:DefaultKeyboardFocusManager.java

示例10: focusLost

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
@Override
public void focusLost(FocusEvent e)
{
    JTextField tf = (JTextField)e.getComponent();
    tf.select(0,0);
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:7,代码来源:DriverCarPanel.java

示例11: focusGained

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e)
{
    JTextField tf = (JTextField)e.getComponent();
    tf.selectAll();
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:7,代码来源:DriverCarPanel.java

示例12: focusGained

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e) {
	JTextField tf = (JTextField)e.getComponent();
	tf.selectAll();
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:6,代码来源:TimeEntry.java

示例13: initComponentsMore

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
private void initComponentsMore(ImportData data, boolean removeUnusedImports) {
    contentPanel.setLayout( new GridBagLayout() );
    contentPanel.setBackground( UIManager.getColor("Table.background") ); //NOI18N
    jScrollPane1.setBorder( UIManager.getBorder("ScrollPane.border") ); //NOI18N
    jScrollPane1.getVerticalScrollBar().setUnitIncrement( new JLabel("X").getPreferredSize().height );
    jScrollPane1.getVerticalScrollBar().setBlockIncrement( new JLabel("X").getPreferredSize().height*10 );
    
    if (data.variants.length > 0 ) {
    
        int row = 0;

        combos = new JComboBox[data.variants.length];

        Font monoSpaced = new Font( "Monospaced", Font.PLAIN, new JLabel().getFont().getSize() );
        FocusListener focusListener = new FocusListener() {
            public void focusGained(FocusEvent e) {
                Component c = e.getComponent();
                Rectangle r = c.getBounds();
                contentPanel.scrollRectToVisible( r );
            }
            public void focusLost(FocusEvent arg0) {
            }
        };
        for (int i=0; i < data.variants.length; i++){
            combos[i] = createComboBox(data.variants[i], data.defaults[i], monoSpaced, focusListener );

            JLabel lblSimpleName = new JLabel(data.simpleNames[i]);
            lblSimpleName.setOpaque( false );
            lblSimpleName.setFont( monoSpaced );
            lblSimpleName.setLabelFor( combos[i] );

            contentPanel.add( lblSimpleName, new GridBagConstraints(0,row,1,1,0.0,0.0,GridBagConstraints.WEST,GridBagConstraints.NONE,new Insets(3,5,2,5),0,0) );
            contentPanel.add( combos[i], new GridBagConstraints(1,row++,1,1,1.0,0.0,GridBagConstraints.WEST,GridBagConstraints.HORIZONTAL,new Insets(3,5,2,5),0,0) );
        }

        contentPanel.add( new JLabel(), new GridBagConstraints(2,row,2,1,0.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(0,0,0,0),0,0) );

        Dimension d = contentPanel.getPreferredSize();
        d.height = getRowHeight() * Math.min(combos.length, 6);
        jScrollPane1.getViewport().setPreferredSize( d );
    } else {
        contentPanel.add( new JLabel(getBundleString("FixDupImportStmts_NothingToFix")), new GridBagConstraints(0,0,1,1,1.0,1.0,GridBagConstraints.CENTER,GridBagConstraints.NONE,new Insets(20,20,20,20),0,0) );
    }
    
    // load localized text into widgets:
    lblTitle.setText(getBundleString("FixDupImportStmts_IntroLbl")); //NOI18N
    lblHeader.setText(getBundleString("FixDupImportStmts_Header")); //NOI18N
    
    checkUnusedImports = new JCheckBox();
    Mnemonics.setLocalizedText(checkUnusedImports, getBundleString("FixDupImportStmts_UnusedImports")); //NOI18N
    bottomPanel.add( checkUnusedImports, BorderLayout.WEST );
    checkUnusedImports.setEnabled(true);
    checkUnusedImports.setSelected(removeUnusedImports);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:55,代码来源:FixDuplicateImportStmts.java

示例14: focusGained

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent e) {
    JComponent c = (JComponent) e.getComponent();
    c.scrollRectToVisible(new Rectangle(0, 0, c.getWidth(), c.getHeight()));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:ListDemo.java

示例15: focusGained

import java.awt.event.FocusEvent; //导入方法依赖的package包/类
@Override
public void focusGained(FocusEvent event)
{
	focus = (EquellaSyntaxTextArea) event.getComponent();
}
 
开发者ID:equella,项目名称:Equella,代码行数:6,代码来源:ExpertScriptingTab.java


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