當前位置: 首頁>>代碼示例>>Java>>正文


Java Keyboard類代碼示例

本文整理匯總了Java中org.lwjgl.input.Keyboard的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard類的具體用法?Java Keyboard怎麽用?Java Keyboard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Keyboard類屬於org.lwjgl.input包,在下文中一共展示了Keyboard類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadMacros

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
public void loadMacros() {
	try {
		File file = new File(xdolfDir.getAbsolutePath(), "macros.txt");
		FileInputStream fstream = new FileInputStream(file.getAbsolutePath());
		DataInputStream in = new DataInputStream(fstream);
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		String line;
		while((line = br.readLine()) != null) {
			String curLine = line.toLowerCase().trim();
			String[] s = curLine.split(":");
			String cmd = s[0];
			int id = Keyboard.getKeyIndex(s[1].toUpperCase());
			Macro m = new Macro(id, cmd);
		}
		br.close();
	} catch(Exception e) {
		e.printStackTrace();
		saveMacros();
	}
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:21,代碼來源:FileManager.java

示例2: initGui

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
/**
 * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
 * window resizes, the buttonList is cleared beforehand.
 */
public void initGui()
{
    this.buttonList.clear();
    Keyboard.enableRepeatEvents(true);

    if (this.bookIsUnsigned)
    {
        this.buttonList.add(this.buttonSign = new GuiButton(3, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.signButton", new Object[0])));
        this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.done", new Object[0])));
        this.buttonList.add(this.buttonFinalize = new GuiButton(5, this.width / 2 - 100, 4 + this.bookImageHeight, 98, 20, I18n.format("book.finalizeButton", new Object[0])));
        this.buttonList.add(this.buttonCancel = new GuiButton(4, this.width / 2 + 2, 4 + this.bookImageHeight, 98, 20, I18n.format("gui.cancel", new Object[0])));
    }
    else
    {
        this.buttonList.add(this.buttonDone = new GuiButton(0, this.width / 2 - 100, 4 + this.bookImageHeight, 200, 20, I18n.format("gui.done", new Object[0])));
    }

    int i = (this.width - this.bookImageWidth) / 2;
    int j = 2;
    this.buttonList.add(this.buttonNextPage = new GuiScreenBook.NextPageButton(1, i + 120, j + 154, true));
    this.buttonList.add(this.buttonPreviousPage = new GuiScreenBook.NextPageButton(2, i + 38, j + 154, false));
    this.updateButtons();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:28,代碼來源:GuiScreenBook.java

示例3: dispatchKeypresses

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
public void dispatchKeypresses()
{
    int i = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();

    if (i != 0 && !Keyboard.isRepeatEvent())
    {
        if (!(this.currentScreen instanceof GuiControls) || ((GuiControls)this.currentScreen).time <= getSystemTime() - 20L)
        {
            if (Keyboard.getEventKeyState())
            {
                if (i == this.gameSettings.keyBindFullscreen.getKeyCode())
                {
                    this.toggleFullscreen();
                }
                else if (i == this.gameSettings.keyBindScreenshot.getKeyCode())
                {
                    this.ingameGUI.getChatGUI().printChatMessage(ScreenShotHelper.saveScreenshot(this.mcDataDir, this.displayWidth, this.displayHeight, this.framebufferMc));
                }
            }
        }
    }
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:23,代碼來源:Minecraft.java

示例4: handleInput

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
/**
 * Delegates mouse and keyboard input.
 */
public void handleInput() throws IOException
{
    if (Mouse.isCreated())
    {
        while (Mouse.next())
        {
            if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Pre(this))) continue;
            this.handleMouseInput();
            if (this.equals(this.mc.currentScreen)) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Post(this));
        }
    }

    if (Keyboard.isCreated())
    {
        while (Keyboard.next())
        {
            if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Pre(this))) continue;
            this.handleKeyboardInput();
            if (this.equals(this.mc.currentScreen)) net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.client.event.GuiScreenEvent.KeyboardInputEvent.Post(this));
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:26,代碼來源:GuiScreen.java

示例5: getKeyId

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
public static int getKeyId(String name) {
    if (name.equals("") || name.equals("NONE")) return Keyboard.KEY_NONE;
    name = name.toUpperCase();
    String param = null;
    if (name.startsWith("MOUSE")) {
        param = name.substring(5);
    }
    if (name.startsWith("BUTTON")) {
        param = name.substring(6);
    }
    if (param != null) {
        try {
            int button = Integer.parseInt(param);
            if (button >= 0 && button < 256) return button | MOUSE;
        } catch (Exception e) {
        }
        return -1;
    }
    int key = Keyboard.getKeyIndex(name.toUpperCase());
    return key;
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:22,代碼來源:KeyHelper.java

示例6: onGuiClosed

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
/**
 * "Called when the screen is unloaded. Used to disable keyboard repeat
 * events."
 */
@Override
public void onGuiClosed()
{
	state = ServerFinderState.CANCELLED;
	WurstClient.INSTANCE.analytics.trackEvent("server finder", "cancel",
		"gui closed", working);
	
	if(MiscUtils.isInteger(maxThreadsBox.getText()))
	{
		WurstClient.INSTANCE.options.serverFinderThreads =
			Integer.valueOf(maxThreadsBox.getText());
		ConfigFiles.OPTIONS.save();
	}
	Keyboard.enableRepeatEvents(false);
}
 
開發者ID:Wurst-Imperium,項目名稱:Wurst-MC-1.12,代碼行數:20,代碼來源:GuiServerFinder.java

示例7: call

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
@Override
public void call(KeyEvent event) {
    int key = Keyboard.KEY_RSHIFT;
    if (event.getKey() == key) {
        if (mc.currentScreen == null) {
            for (KeyBinding keyBinding : mc.gameSettings.keyBindings)
                if (keyBinding.getKeyCode() == key)
                    return;
            if (!wasSetUp) {
                setup(guiManager);
                wasSetUp = true;
            }
            mc.displayGuiScreen(new GuiSerenity(guiManager));
        }
    }
}
 
開發者ID:SerenityEnterprises,項目名稱:SerenityCE,代碼行數:17,代碼來源:SerenityPluginGui.java

示例8: onBlockActivated

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if(!worldIn.isRemote) {
        if(playerIn.inventory.getCurrentItem().getItem() == MItems.WRENCH) {
            TileEntityAccumulator tile = (TileEntityAccumulator) worldIn.getTileEntity(pos);
            EnumFacing face = facing;
            if(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)){
                face = face.getOpposite();
            }
            AccumulatorInfo info = tile.getInfoForFace(face);
            tile.getInfoForFace(face).setIoInfo(info.getIoInfo().getNext());
            tile.markDirty();
            return true;
        } else
            playerIn.openGui(MAS.INSTANCE, 1, worldIn, pos.getX(), pos.getY(), pos.getZ());
    }
    return true;
}
 
開發者ID:jaredlll08,項目名稱:Machines-and-Stuff,代碼行數:19,代碼來源:BlockAccumulator.java

示例9: initGui

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
/**
 * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
 * window resizes, the buttonList is cleared beforehand.
 */
public void initGui()
{
    Keyboard.enableRepeatEvents(true);
    this.buttonList.clear();
    this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 18, I18n.format("addServer.add", new Object[0])));
    this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 18, I18n.format("gui.cancel", new Object[0])));
    this.buttonList.add(this.serverResourcePacks = new GuiButton(2, this.width / 2 - 100, this.height / 4 + 72, I18n.format("addServer.resourcePack", new Object[0]) + ": " + this.serverData.getResourceMode().getMotd().getFormattedText()));
    this.serverNameField = new GuiTextField(0, this.fontRendererObj, this.width / 2 - 100, 66, 200, 20);
    this.serverNameField.setFocused(true);
    this.serverNameField.setText(this.serverData.serverName);
    this.serverIPField = new GuiTextField(1, this.fontRendererObj, this.width / 2 - 100, 106, 200, 20);
    this.serverIPField.setMaxStringLength(128);
    this.serverIPField.setText(this.serverData.serverIP);
    this.serverIPField.func_175205_a(this.field_181032_r);
    ((GuiButton)this.buttonList.get(0)).enabled = this.serverIPField.getText().length() > 0 && this.serverIPField.getText().split(":").length > 0 && this.serverNameField.getText().length() > 0;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:GuiScreenAddServer.java

示例10: initGui

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
@Override
public void initGui()
{
    Keyboard.enableRepeatEvents(true);

    this.guiLeft = (this.width - this.xSize) / 2;
    this.guiTop = (this.height - this.ySize) / 2;

    buttonList.clear();
    buttonList.add(new GuiButton(ID_CONFIRM, guiLeft + (xSize - 50) / 2, guiTop + ySize + 2, 50, 20, I18n.translateToLocal("gui.done")));
    buttonList.add(new GuiButton(ID_WIRELESS_ORDER, guiLeft + xSize + 1, guiTop , 20, 20, ""));
    buttonList.add(new GuiButton(ID_UP, guiLeft + xSize + 1, guiTop + 21 , 20, 20, "^"));
    buttonList.add(new GuiButton(ID_DOWN, guiLeft + xSize + 1, guiTop + 41, 20, 20, "v"));

    channels = new ArrayList<>(master.wirelessPos);
    trackList = new GuiWirelessList(this, 93 - 10, ySize - 22, guiTop + 11, guiTop + ySize - 5, guiLeft + 5, 8, channels);

    rotateX = 0F;
    rotateY = 0F;

    releasedMouse = false;
}
 
開發者ID:iChun,項目名稱:GeneralLaymansAestheticSpyingScreen,代碼行數:23,代碼來源:GuiWirelessOrder.java

示例11: initGui

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
/**
 * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
 * window resizes, the buttonList is cleared beforehand.
 */
public void initGui()
{
    this.buttonList.clear();
    Keyboard.enableRepeatEvents(true);
    this.presetsTitle = I18n.format("createWorld.customize.presets.title", new Object[0]);
    this.presetsShare = I18n.format("createWorld.customize.presets.share", new Object[0]);
    this.listText = I18n.format("createWorld.customize.presets.list", new Object[0]);
    this.export = new GuiTextField(2, this.fontRendererObj, 50, 40, this.width - 100, 20);
    this.list = new GuiFlatPresets.ListSlot();
    this.export.setMaxStringLength(1230);
    this.export.setText(this.parentScreen.getPreset());
    this.btnSelect = this.addButton(new GuiButton(0, this.width / 2 - 155, this.height - 28, 150, 20, I18n.format("createWorld.customize.presets.select", new Object[0])));
    this.buttonList.add(new GuiButton(1, this.width / 2 + 5, this.height - 28, 150, 20, I18n.format("gui.cancel", new Object[0])));
    this.updateButtonValidity();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:20,代碼來源:GuiFlatPresets.java

示例12: initGui

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
/**
 * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
 * window resizes, the buttonList is cleared beforehand.
 */
public void initGui()
{
    Keyboard.enableRepeatEvents(true);
    this.buttonList.clear();
    this.buttonList.add(this.doneBtn = new GuiButton(0, this.width / 2 - 4 - 150, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.done", new Object[0])));
    this.buttonList.add(this.cancelBtn = new GuiButton(1, this.width / 2 + 4, this.height / 4 + 120 + 12, 150, 20, I18n.format("gui.cancel", new Object[0])));
    this.buttonList.add(this.field_175390_s = new GuiButton(4, this.width / 2 + 150 - 20, 150, 20, 20, "O"));
    this.commandTextField = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 150, 50, 300, 20);
    this.commandTextField.setMaxStringLength(32767);
    this.commandTextField.setFocused(true);
    this.commandTextField.setText(this.localCommandBlock.getCommand());
    this.previousOutputTextField = new GuiTextField(3, this.fontRendererObj, this.width / 2 - 150, 150, 276, 20);
    this.previousOutputTextField.setMaxStringLength(32767);
    this.previousOutputTextField.setEnabled(false);
    this.previousOutputTextField.setText("-");
    this.field_175389_t = this.localCommandBlock.shouldTrackOutput();
    this.func_175388_a();
    this.doneBtn.enabled = this.commandTextField.getText().trim().length() > 0;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:24,代碼來源:GuiCommandBlock.java

示例13: onGuiClosed

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
/**
 * Called when the screen is unloaded. Used to disable keyboard repeat events
 */
public void onGuiClosed()
{
    Keyboard.enableRepeatEvents(false);
    this.mc.gameSettings.lastServer = this.ipEdit.getText();
    this.mc.gameSettings.saveOptions();
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:10,代碼來源:GuiScreenServerList.java

示例14: onDisable

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
@Override
protected void onDisable() {
    if (!Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode())) {
        KeyBinding.setKeyBindState(mc.gameSettings.keyBindSneak.getKeyCode(), false);
        if (this.sneaking) {
            mc.thePlayer.sendQueue.addToSendQueue(new C0BPacketEntityAction(mc.thePlayer, C0BPacketEntityAction.Action.STOP_SNEAKING));
            this.sneaking = false;
        }
    }

    this.sneaking = false;
}
 
開發者ID:SerenityEnterprises,項目名稱:SerenityCE,代碼行數:13,代碼來源:Sneak.java

示例15: onGuiClosed

import org.lwjgl.input.Keyboard; //導入依賴的package包/類
/**
 * Called when the screen is unloaded. Used to disable keyboard repeat events
 */
public void onGuiClosed()
{
    super.onGuiClosed();
    Keyboard.enableRepeatEvents(false);
    this.inventorySlots.removeCraftingFromCrafters(this);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:10,代碼來源:GuiRepair.java


注:本文中的org.lwjgl.input.Keyboard類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。