Java Code Examples for javax.swing.JComponent.requestFocus()

The following are Jave code examples for showing how to use requestFocus() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: QuietEditorPane.java   View Source Code Vote up 6 votes
private void requestFocus(JComponent comp) {
    Container container = SwingUtilities.getAncestorOfClass(TopComponent.class, comp);
    if (container != null) {
        ((TopComponent)container).requestActive();
    }
    else {
        Component f = comp;
        do {
            f = f.getParent();
            if (f instanceof Frame) {
                break;
            }
        } while (f != null);
        if (f != null) {
            f.requestFocus();
        }
        comp.requestFocus();
    }
}
 
Example 2
Project: VASSAL-src   File: WizardDisplayerImpl.java   View Source Code Vote up 6 votes
void handleSummary(Summary summary)
{
    inSummary = true;
    JComponent summaryComp = (JComponent) summary.getSummaryComponent(); // XXX
    if (summaryComp.getBorder() != null)
    {
        CompoundBorder b = new CompoundBorder(new EmptyBorder(5, 5, 5, 5), summaryComp
            .getBorder());
        summaryComp.setBorder(b);
    }
    setCurrentWizardPanel(summaryComp); // XXX
    instructions.setInSummaryPage(true);
    ttlLabel.setText(NbBridge.getString("org/netbeans/api/wizard/Bundle", // NOI18N
                                        WizardDisplayerImpl.class, "Summary")); // NOI18N
    getButtonManager().setSummaryShowingMode();
    summaryComp.requestFocus();
    
}
 
Example 3
Project: incubator-netbeans   File: TerminalContainerCommon.java   View Source Code Vote up 5 votes
@Override
   public void requestFocus() {
// redirect focus into terminal
JComponent selected = getSelected();
if (selected != null) {
    selected.requestFocus();
} else {
    super.requestFocus();
}
   }
 
Example 4
Project: incubator-netbeans   File: IOWindow.java   View Source Code Vote up 5 votes
@Override
public void requestActive() {
    super.requestActive();
    JComponent tab = getSelectedTab();
    if (tab != null) {
        tab.requestFocus();
    }
}
 
Example 5
Project: incubator-netbeans   File: StringTableCellEditor.java   View Source Code Vote up 5 votes
@Override
public Component getTableCellEditorComponent(final JTable table, Object value, boolean isSelected, final int row, final int column) {
    final JComponent c = (JComponent) super.getTableCellEditorComponent(table, value, isSelected, row, column);      
    
    this.tableModel = table.getModel();
    this.columnName = table.getColumnName(column);
    this.modelRow = table.convertRowIndexToModel(row);
    this.modelColumn = table.convertColumnIndexToModel(column);  
    this.tc = c instanceof JTextComponent ? (JTextComponent) c : null;

    JPanel panel = new JPanel(new BorderLayout()) {
        @Override
        public void addNotify() {
            super.addNotify();
            c.requestFocus();
        }
    };
    panel.add(c);
    if (suppressEditorBorder) {
        c.setBorder(BorderFactory.createEmptyBorder());
    }
    panel.add(customEditorButton, BorderLayout.EAST);
    panel.revalidate();
    panel.repaint();

    return panel;
}
 
Example 6
Project: VASSAL-src   File: WizardDisplayerImpl.java   View Source Code Vote up 5 votes
/** 
 * Set the currently displayed panel.
 * @parm comp is can be anything - it is not required to be a WizardPage or WizardPanel 
 * */
public void setCurrentWizardPanel(JComponent comp)
{
    inner.add(comp, BorderLayout.CENTER);
    inner.remove(wizardPanel);
    wizardPanel = comp;
    inner.invalidate();
    inner.revalidate();
    inner.repaint();
    comp.requestFocus();
    if (!inSummary)
    {
        buttonManager.updateButtons();
    }
}
 
Example 7
Project: sbc-qsystem   File: FMedCheckIn.java   View Source Code Vote up 5 votes
private void setFordFocuseEdit(final JComponent e) {
    e.requestFocus();
    e.requestFocusInWindow();
    // фокус для приема данных со сканера штрих-кодов
    java.awt.EventQueue.invokeLater(() -> {
        e.requestFocus();
    });
}