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


Java KeyStroke.getCharacter方法代码示例

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


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

示例1: main

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
public static void main(String[] args) throws InterruptedException, IOException {
    Terminal terminal = new TestTerminalFactory(args).createTerminal();
    terminal.enterPrivateMode();
    terminal.clearScreen();
    terminal.setCursorPosition(10, 5);
    terminal.putCharacter('H');
    terminal.putCharacter('e');
    terminal.putCharacter('l');
    terminal.putCharacter('l');
    terminal.putCharacter('o');
    terminal.putCharacter('!');
    terminal.setCursorPosition(0, 0);
    terminal.addResizeListener(new TerminalResizeTest());

    while(true) {
        KeyStroke key = terminal.pollInput();
        if(key == null || key.getCharacter() != 'q') {
            Thread.sleep(1);
        }
        else {
            break;
        }
    }
    terminal.exitPrivateMode();
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:26,代码来源:TerminalResizeTest.java

示例2: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(KeyStroke keyStroke) {
	Runnable selectedItem = getSelectedItem();
	KeyType keyType = keyStroke.getKeyType();
	if (selectedItem != null
			&& (keyType == KeyType.Enter || (keyType == KeyType.Character && keyStroke.getCharacter() == ' '))) {
		selectedItem.run();
		return Result.HANDLED;
	}
	if (keyType == KeyType.Character) {
		selectItem(keyStroke.getCharacter());
	}
	if (keyType == KeyType.Escape) {
		closeListener.run();
		return Result.HANDLED;
	}
	return super.handleKeyStroke(keyStroke);
}
 
开发者ID:BrunoEberhard,项目名称:minimal-j,代码行数:19,代码来源:MenuItemListBox.java

示例3: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(KeyStroke keyStroke) {
    Object selectedItem = getSelectedItem();
    if(selectedItem != null &&
            (keyStroke.getKeyType() == KeyType.Enter ||
            (keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' '))) {

        ((Runnable)selectedItem).run();
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:13,代码来源:ActionListBox.java

示例4: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public synchronized Result handleKeyStroke(KeyStroke keyStroke) {
    if(keyStroke.getKeyType() == KeyType.Enter ||
            (keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' ')) {
        if(itemStatus.get(getSelectedIndex()))
            itemStatus.set(getSelectedIndex(), Boolean.FALSE);
        else
            itemStatus.set(getSelectedIndex(), Boolean.TRUE);
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:13,代码来源:CheckBoxList.java

示例5: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public Result handleKeyStroke(KeyStroke keyStroke) {
    if((keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' ') ||
            keyStroke.getKeyType() == KeyType.Enter) {
        setChecked(!isChecked());
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:10,代码来源:CheckBox.java

示例6: handleKeyStroke

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
@Override
public synchronized Result handleKeyStroke(KeyStroke keyStroke) {
    if(keyStroke.getKeyType() == KeyType.Enter ||
            (keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' ')) {
        checkedIndex = getSelectedIndex();
        invalidate();
        return Result.HANDLED;
    }
    return super.handleKeyStroke(keyStroke);
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:11,代码来源:RadioBoxList.java

示例7: isCtrlC

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
private void isCtrlC(KeyStroke key) throws IOException {
    if(key != null
            && terminalCtrlCBehaviour == CtrlCBehaviour.CTRL_C_KILLS_APPLICATION
            && key.getCharacter() != null
            && key.getCharacter() == 'c'
            && !key.isAltDown()
            && key.isCtrlDown()) {
   
        exitPrivateMode();
        System.exit(1);
    }
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:13,代码来源:UnixLikeTerminal.java

示例8: main

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, InterruptedException {
    Terminal terminal = new TestTerminalFactory(args).createTerminal();
    if(terminal instanceof SwingTerminalFrame) {
        ((SwingTerminalFrame) terminal).setAutoCloseTrigger(SwingTerminalFrame.AutoCloseTrigger.DoNotAutoClose);
    }
    boolean normalTerminal = true;
    printNormalTerminalText(terminal);
    KeyStroke keyStroke = null;
    while(keyStroke == null || keyStroke.getKeyType() != KeyType.Escape) {
        keyStroke = terminal.pollInput();
        if(keyStroke != null && keyStroke.getKeyType() == KeyType.Character && keyStroke.getCharacter() == ' ') {
            normalTerminal = !normalTerminal;
            if(normalTerminal) {
                terminal.exitPrivateMode();
                printNormalTerminalText(terminal);
            }
            else {
                terminal.enterPrivateMode();
                printPrivateModeTerminalText(terminal);
            }
        }
        else {
            Thread.sleep(1);
        }
    }
    if(!normalTerminal) {
        terminal.exitPrivateMode();
    }
    terminal.putCharacter('\n');
    if(terminal instanceof SwingTerminalFrame) {
        ((SwingTerminalFrame) terminal).dispose();
    }
}
 
开发者ID:Truth0906,项目名称:lanterna,代码行数:34,代码来源:PrivateModeTest.java

示例9: mapVirtualKey

import com.googlecode.lanterna.input.KeyStroke; //导入方法依赖的package包/类
private int mapVirtualKey(KeyStroke key) {
        switch (key.getKeyType()) {
        case Character:     return key.getCharacter();
        
        case Escape:        return KeyEvent.VK_ESCAPE;
        case Backspace:     return KeyEvent.VK_BACK_SPACE;
        case ArrowLeft:     return KeyEvent.VK_LEFT;
        case ArrowRight:    return KeyEvent.VK_RIGHT;
        case ArrowUp:       return KeyEvent.VK_UP;
        case ArrowDown:     return KeyEvent.VK_DOWN;
        case Insert:        return KeyEvent.VK_INSERT;
        case Delete:        return KeyEvent.VK_DELETE;
        case Home:          return KeyEvent.VK_HOME;
        case End:           return KeyEvent.VK_END;
        case PageUp:        return KeyEvent.VK_PAGE_UP;
        case PageDown:      return KeyEvent.VK_PAGE_DOWN;
        case Tab:           return KeyEvent.VK_TAB;
//        case ReverseTab:    return KeyEvent.VK_UNDEFINED;
        case Enter:         return KeyEvent.VK_ENTER;
        
        case F1:            return KeyEvent.VK_F1;
        case F2:            return KeyEvent.VK_F2;
        case F3:            return KeyEvent.VK_F3;
        case F4:            return KeyEvent.VK_F4;
        case F5:            return KeyEvent.VK_F5;
        case F6:            return KeyEvent.VK_F6;
        case F7:            return KeyEvent.VK_F7;
        case F8:            return KeyEvent.VK_F8;
        case F9:            return KeyEvent.VK_F9;
        case F10:           return KeyEvent.VK_F10;
        case F11:           return KeyEvent.VK_F11;
        case F12:           return KeyEvent.VK_F12;
        case F13:           return KeyEvent.VK_F13;
        case F14:           return KeyEvent.VK_F14;
        case F15:           return KeyEvent.VK_F15;
        case F16:           return KeyEvent.VK_F16;
        case F17:           return KeyEvent.VK_F17;
        case F18:           return KeyEvent.VK_F18;
        case F19:           return KeyEvent.VK_F19;
        }
        
        return KeyEvent.VK_UNDEFINED;
    }
 
开发者ID:viktor-podzigun,项目名称:charva-lanterna,代码行数:44,代码来源:LanternaToolkit.java


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