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


Java KeyEvent.VK_TAB属性代码示例

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


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

示例1: keyPressed

@Override
public void keyPressed(KeyEvent e) {            
    shouldHide = false;
    switch (e.getKeyCode()) {
        case KeyEvent.VK_ENTER:
            shouldHide = true;
            break;
        case KeyEvent.VK_ESCAPE:
            shouldHide = true;
            break;
        case KeyEvent.VK_TAB:
            setSelectedItem(getSearchString());
            shouldHide = true;
        default:
            break;
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:AutoSuggest.java

示例2: usableKeyOnMac

private static boolean usableKeyOnMac(int key, int mask) {
    //All permutations fail for Q except ctrl
    if (key == KeyEvent.VK_Q) {
        return false;
    }

    boolean isMeta = ((mask & KeyEvent.META_MASK) != 0) || ((mask & KeyEvent.CTRL_DOWN_MASK) != 0);

    boolean isAlt = ((mask & KeyEvent.ALT_MASK) != 0) || ((mask & KeyEvent.ALT_DOWN_MASK) != 0);

    boolean isOnlyMeta = isMeta && ((mask & ~(KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK)) == 0);

    //Mac OS consumes keys Command+ these keys - the app will never see
    //them, so CTRL should not be remapped for these
    if (isOnlyMeta) {
        return (key != KeyEvent.VK_H) && (key != KeyEvent.VK_SPACE) && (key != KeyEvent.VK_TAB);
    }
    if ((key == KeyEvent.VK_D) && isMeta && isAlt) {
        return false;
    }
    if (key == KeyEvent.VK_SPACE && isMeta && ((mask & KeyEvent.CTRL_MASK) != 0)) {
        // http://lists.apple.com/archives/java-dev/2010/Aug/msg00002.html
        return false;
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:Utilities.java

示例3: processKeyEvent

@Override
public void processKeyEvent(KeyEvent e) {
    //Manually hook in the bindings for tab - does not seem to get called
    //automatically
    if (isEditing() && ((e.getKeyCode() == KeyEvent.VK_DOWN) || (e.getKeyCode() == KeyEvent.VK_UP))) {
        return; //XXX
    }

    //Bypass standard tab and escape handling, and use our registered
    //actions instead
    if (
        !isEditing() ||
            (((e.getKeyCode() != KeyEvent.VK_TAB) && (e.getKeyCode() != KeyEvent.VK_ESCAPE)) ||
            ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0))
    ) {
        super.processKeyEvent(e);
    } else {
        processKeyBinding(
            KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiersEx(), e.getID() == KeyEvent.KEY_RELEASED), e,
            JComponent.WHEN_FOCUSED, e.getID() == KeyEvent.KEY_PRESSED
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:TreeTable.java

示例4: passToSearchField

void passToSearchField(KeyEvent e) {
    if (! isQuickSearchAllowed()) {
        return;
    }

    //Don't do anything for normal navigation keys
    if (
        (e.getKeyCode() == KeyEvent.VK_TAB) || (e.getKeyCode() == KeyEvent.VK_ENTER) ||
            (((e.getKeyCode() == KeyEvent.VK_UP) || (e.getKeyCode() == KeyEvent.VK_DOWN)) &&
            ((searchField == null) || !searchField.isShowing()))
    ) {
        return;
    }

    if (getRowCount() == 0) {
        return;
    }

    if ((searchField == null) || !searchField.isShowing()) {
        showSearchField();
        searchField.setText(String.valueOf(e.getKeyChar()));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:BaseTable.java

示例5: keyPressed

@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_ESCAPE) {
        removeSearchField();
        ETable.this.requestFocus();
    } else if (keyCode == KeyEvent.VK_UP) {
        currentSelectionIndex--;
        displaySearchResult();
        // Stop processing the event here. Otherwise it's dispatched
        // to the table too (which scrolls)
        e.consume();
    } else if (keyCode == KeyEvent.VK_DOWN) {
        currentSelectionIndex++;
        displaySearchResult();
        // Stop processing the event here. Otherwise it's dispatched
        // to the table too (which scrolls)
        e.consume();
    } else if (keyCode == KeyEvent.VK_TAB) {
        if (maxPrefix != null) {
            searchTextField.setText(maxPrefix);
        }
        e.consume();
    } else if (keyCode == KeyEvent.VK_ENTER) {
        removeSearchField();
        
        // TODO: do something on hitting enter???
        e.consume();
        ETable.this.requestFocus();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ETable.java

示例6: keyPressed

@Override
public void keyPressed(KeyEvent ke) {
	
	int keyCode = ke.getKeyCode();
	Object keSource = ke.getSource();
	JTextField jTextField = (JTextField) keSource;;
	int caretPos = jTextField.getCaretPosition();
	int textLength = jTextField.getText().length();
	
	if(keyCode == KeyEvent.VK_ESCAPE){
		// Due to a java bug, the callback method is not called automatically when pressing escape.
		cancelCellEditing();
	} else if(keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_TAB){
		// Remember which key was used to confirm editing
		confirmationKey = keyCode;
	} else if(keyCode==KeyEvent.VK_RIGHT && caretPos==textLength){
		confirmationKey = keyCode;
		stopCellEditing();
	} else if(keyCode==KeyEvent.VK_LEFT && caretPos==0){
		confirmationKey = keyCode;
		stopCellEditing();
	}
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:BasicCellEditor.java

示例7: keyPressed

@Override
public void keyPressed(KeyEvent e) {
	if(e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_TAB){
		try {
			((JSpinner)editorComponent).commitEdit();
			
		} catch (ParseException e1) {
			DefaultEditor de = (DefaultEditor) ((JSpinner)editorComponent).getEditor();
			String text = de.getTextField().getText();
			if(text.matches("^\\d+(\\.\\d*)?")){
				((JSpinner)editorComponent).setValue(Float.parseFloat(text));
			}else{
				System.err.println("Invalid input - ignoring");
			}
		}
	}
	super.keyPressed(e);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:18,代码来源:TableCellSpinnerEditor4FloatObject.java

示例8: keyTyped

@Override
public void keyTyped(KeyEvent ke) {       
    if(ke.getKeyCode() == KeyEvent.VK_LEFT ||
            ke.getKeyCode() == KeyEvent.VK_RIGHT ||
            ke.getKeyCode() == KeyEvent.VK_UP ||
            ke.getKeyCode() == KeyEvent.VK_DOWN) {
        return;
    }
    
    if(pane.getSelectedText() != null ||  
            ke.getKeyChar()== KeyEvent.VK_DELETE ||
            ke.getKeyChar()== KeyEvent.VK_BACK_SPACE ||
            (ke.isShiftDown() && ke.getKeyChar() == KeyEvent.VK_TAB)) {            
        try {
            prevText = pane.getStyledDocument().getText(0, pane.getStyledDocument().getLength());
        } catch (BadLocationException ex) {
            Logger.getLogger(SaveTextBeforeRemove.class.getName()).log(Level.SEVERE, null, ex);
        }
    }        
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:20,代码来源:SaveTextBeforeRemove.java

示例9: testCreateNewfileCEditor

@Test
public void testCreateNewfileCEditor() throws InterruptedException {
    CElectionDescriptionEditor electionDescriptionEditor = helper.getCEditorOfCurrentInstace();
    ElectionDescription electionDescription = electionDescriptionEditor.getElectionDescription();
    Assert.assertEquals(electionDescription.getInputType().getInputID(),
            ElectionTypeContainer.ElectionInputTypeIds.SINGLE_CHOICE);

    electionDescriptionEditor.setVisible(true);
    helper.clickMenuItemInCEditor(0,0,waittime);

    int[] keys = {
            KeyEvent.VK_DOWN, KeyEvent.VK_DOWN, KeyEvent.VK_ENTER, //choose new election input
            KeyEvent.VK_TAB, //switch to name field
            KeyEvent.VK_N, //type new name
            KeyEvent.VK_ENTER //clicks apply
    };

    helper.performKeystrokes(keys, 50);
    electionDescription = electionDescriptionEditor.getElectionDescription();
    Assert.assertEquals(electionDescription.getInputType().getInputID(),
            ElectionTypeContainer.ElectionInputTypeIds.PREFERENCE);

    helper.endInstance();
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:24,代码来源:GuiTestCEditor.java

示例10: keyPressed

@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();

    if (keyCode == KeyEvent.VK_ESCAPE) {
        removeSearchField();
        NbList.this.requestFocus();
    } else if (keyCode == KeyEvent.VK_UP) {
        currentSelectionIndex--;
        displaySearchResult();

        // Stop processing the event here. Otherwise it's dispatched
        // to the tree too (which scrolls)
        e.consume();
    } else if (keyCode == KeyEvent.VK_DOWN) {
        currentSelectionIndex++;
        displaySearchResult();

        // Stop processing the event here. Otherwise it's dispatched
        // to the tree too (which scrolls)
        e.consume();
    } else if (keyCode == KeyEvent.VK_TAB) {
        if (maxPrefix != null) {
            searchTextField.setText(maxPrefix);
        }

        e.consume();
    } else if (keyCode == KeyEvent.VK_ENTER) {
        removeSearchField();
        NbList.this.requestFocus();
        NbList.this.dispatchEvent(e);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:ListView.java

示例11: getTextForKeyChar

public static String getTextForKeyChar(char keyChar) {
    int keycode;
    switch (keyChar) {
    case ' ':
        keycode = KeyEvent.VK_SPACE;
        break;
    case '\b':
        keycode = KeyEvent.VK_BACK_SPACE;
        break;
    case '\t':
        keycode = KeyEvent.VK_TAB;
        break;
    case '\n':
        keycode = KeyEvent.VK_ENTER;
        break;
    case '\u0018':
        keycode = KeyEvent.VK_CANCEL;
        break;
    case '\u001b':
        keycode = KeyEvent.VK_ESCAPE;
        break;
    case '\u007f':
        keycode = KeyEvent.VK_DELETE;
        break;
    default:
        return "" + keyChar;
    }
    return (String) keyCodes.get(Integer.valueOf(keycode));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:29,代码来源:KeyStrokeParser.java

示例12: isCompletionKey

private boolean isCompletionKey (int keyCode, JTextField textField) {
    if (keyCode == KeyEvent.VK_ENTER || keyCode == KeyEvent.VK_TAB) {
        return true;
    }
    if (keyCode == KeyEvent.VK_RIGHT && 
            (textField.getCaretPosition() >= (textField.getDocument().getLength() - 1))) {
        return true;
    }
    
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:FileCompletionPopup.java

示例13: keyPressed

@Override
public void keyPressed(KeyEvent evt) {
    showPopupCompletion = true;
    int keyCode = evt.getKeyCode();
    // #105801: completionPopup might not be ready when updateCompletions not called (empty text field)
    if (completionPopup != null && !completionPopup.isVisible()) {
        if (keyCode == KeyEvent.VK_ENTER) {
            File file = getFileChooser().getFileSystemView().createFileObject(filenameTextField.getText());
            if(file.exists() && file.isDirectory()) {
                setSelected(new File[] {file});
                fileChooser.approveSelection();
                if (file.getParentFile() == null) {
                    // this will hopefully prevent popup to take inappropriate action
                    evt.consume();
                }
            }
        }
        
        if ((keyCode == KeyEvent.VK_TAB || keyCode == KeyEvent.VK_DOWN) ||
            (keyCode == KeyEvent.VK_RIGHT && 
            (filenameTextField.getCaretPosition() >= (filenameTextField.getDocument().getLength() - 1)))) {
            updateCompletions();
        }
        
    }
    
    if(filenameTextField.isFocusOwner() && 
            (completionPopup == null || !completionPopup.isVisible()) &&
            keyCode == KeyEvent.VK_ESCAPE) {
        fileChooser.cancelSelection();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:DirectoryChooserUI.java

示例14: jTextVMOptionsKeyPressed

private void jTextVMOptionsKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextVMOptionsKeyPressed
    if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
        evt.consume();
    }
    if (evt.getKeyCode() == KeyEvent.VK_TAB) {
        if (evt.getModifiers() > 0) {
            jTextVMOptions.transferFocusBackward();
        } else {
            jTextVMOptions.transferFocus();
        }
        evt.consume();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:CustomizerRun.java

示例15: stopCellEditing

@Override
public boolean stopCellEditing() {
	table.setRowHeight(row, originalRowHeight);
	if(confirmationKey == KeyEvent.VK_ENTER && row < table.getRowCount()){
		table.changeSelection(row+1, column, false, false);
	}else if(confirmationKey == KeyEvent.VK_TAB && column< table.getColumnCount()){
		table.changeSelection(row, column+1, false, false);
	}else{
		table.changeSelection(row, column, false, false);
	}
	return super.stopCellEditing();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:12,代码来源:BasicCellEditor.java


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