Java Code Examples for net.minecraft.client.gui.GuiTextField#setMaxStringLength()

The following examples show how to use net.minecraft.client.gui.GuiTextField#setMaxStringLength() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GuiPortScanner.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void initGui() {
    Keyboard.enableRepeatEvents(true);

    hostField = new GuiTextField(0, Fonts.font40, width / 2 - 100, 60, 200, 20);
    hostField.setFocused(true);
    hostField.setMaxStringLength(Integer.MAX_VALUE);
    hostField.setText("localhost");

    minPortField = new GuiTextField(1, Fonts.font40, width / 2 - 100, 90, 90, 20);
    minPortField.setMaxStringLength(5);
    minPortField.setText(String.valueOf(1));

    maxPortField = new GuiTextField(2, Fonts.font40, width / 2 + 10, 90, 90, 20);
    maxPortField.setMaxStringLength(5);
    maxPortField.setText(String.valueOf(65535));

    threadsField = new GuiTextField(3, Fonts.font40, width / 2 - 100, 120, 200, 20);
    threadsField.setMaxStringLength(Integer.MAX_VALUE);
    threadsField.setText(String.valueOf(500));

    buttonList.add(buttonToggle = new GuiButton(1, width / 2 - 100, height / 4 + 95, running ? "Stop" : "Start"));
    buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 120, "Back"));
    buttonList.add(new GuiButton(2, width / 2 - 100, height / 4 + 155, "Export"));
    super.initGui();
}
 
Example 2
Source File: GuiSolderingStation.java    From ExtraCells1 with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
	int posX = (this.width - xSize) / 2;
	int posY = (this.height - ySize) / 2;

	if (rightItem)
	{
		this.buttonList.clear();
		this.buttonList.add(new GuiButton(0, posX + 5, posY + 17, 40, 20, "- 2048"));
		this.buttonList.add(new GuiButton(1, posX + 130, posY + 17, 40, 20, "+ 2048"));
		this.buttonList.add(new GuiButton(2, posX + 5, posY + 47, 40, 20, "- 1"));
		this.buttonList.add(new GuiButton(3, posX + 130, posY + 47, 40, 20, "+ 1"));

		textfield_size = new GuiTextField(fontRenderer, posX + 40, posY + 20, 90, 15);
		textfield_size.setFocused(false);
		textfield_size.setMaxStringLength(12);

		textfield_types = new GuiTextField(fontRenderer, posX + 40, posY + 50, 90, 15);
		textfield_types.setFocused(false);
		textfield_types.setMaxStringLength(2);
	}
}
 
Example 3
Source File: ChangeBackgroundGui.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void initGui() {
    downloadUrlField = new GuiTextField(0, mc.fontRendererObj, width / 4, height / 2 - 10, width / 2, 20);
    downloadUrlField.setFocused(true);
    downloadUrlField.setMaxStringLength(150);
    buttonList.add(new GuiButton(1, width / 2 - 150 / 2, height / 2 + 20, 150, 20,
        I18n.format("button.changebackground.seturl")));
    buttonList.add(new GuiButton(2, width / 2 - 150 / 2, height / 2 + 42, 150, 20,
        I18n.format("button.changebackground.choosefile")));
    buttonList.add(new GuiButton(3, width / 2 - 150 / 2, height / 2 + 64, 150, 20,
        I18n.format("button.changebackground.resetbackground")));
    buttonList.add(new GuiButton(4, width / 2 - 150 / 2, height / 2 + 86, 150, 20,
        I18n.format("gui.cancel")));

    if (Minecraft.getMinecraft().isFullScreen()) Minecraft.getMinecraft().toggleFullscreen();
}
 
Example 4
Source File: CreateServerButton.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void initGui() {
    serverName = new GuiTextField(0, fontRendererObj, width / 2 - 100, height / 2 - 28, 200, 20);
    serverName.setFocused(true);
    serverName.setMaxStringLength(32);
    serverName.setText(Settings.SERVER_BUTTON_NAME);

    serverIp = new GuiTextField(1, fontRendererObj, width / 2 - 100, height / 2 - 4, 200, 20);
    serverIp.setFocused(false);
    serverIp.setMaxStringLength(72);
    serverIp.setText(Settings.SERVER_IP);

    if (serverName.isFocused()) {
        currentlyFocusedField = serverName;
    } else if (serverIp.isFocused()) {
        currentlyFocusedField = serverIp;
    }

    buttonList.add(new GuiButton(2, width / 2 - 100, height / 2 + 20, I18n.format("gui.done")));
}
 
Example 5
Source File: GuiDirectLogin.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public void initGui() {
    Keyboard.enableRepeatEvents(true);
    buttonList.add(loginButton = new GuiButton(1, width / 2 - 100, height / 4 + 72, "Login"));
    buttonList.add(clipboardLoginButton = new GuiButton(2, width / 2 - 100, height / 4 + 96, "Clipboard Login"));
    buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 120, "Back"));
    username = new GuiTextField(2, Fonts.font40, width / 2 - 100, 60, 200, 20);
    username.setFocused(true);
    username.setMaxStringLength(Integer.MAX_VALUE);
    password = new GuiPasswordField(3, Fonts.font40, width / 2 - 100, 85, 200, 20);
    password.setMaxStringLength(Integer.MAX_VALUE);
}
 
Example 6
Source File: GuiChangeName.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public void initGui() {
    Keyboard.enableRepeatEvents(true);
    buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96, "Change"));
    buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 120, "Back"));

    name = new GuiTextField(2, Fonts.font40, width / 2 - 100, 60, 200, 20);
    name.setFocused(true);
    name.setText(mc.getSession().getUsername());
    name.setMaxStringLength(16);
}
 
Example 7
Source File: GuiAdd.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public void initGui() {
    Keyboard.enableRepeatEvents(true);
    buttonList.add(addButton = new GuiButton(1, width / 2 - 100, height / 4 + 72, "Add"));
    buttonList.add(clipboardButton = new GuiButton(2, width / 2 - 100, height / 4 + 96, "Clipboard"));
    buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 120, "Back"));
    username = new GuiTextField(2, Fonts.font40, width / 2 - 100, 60, 200, 20);
    username.setFocused(true);
    username.setMaxStringLength(Integer.MAX_VALUE);
    password = new GuiPasswordField(3, Fonts.font40, width / 2 - 100, 85, 200, 20);
    password.setMaxStringLength(Integer.MAX_VALUE);
}
 
Example 8
Source File: GuiQuantumComputer.java    From qcraft-mod with Apache License 2.0 5 votes vote down vote up
@Override
public void initGui()
{
    super.initGui();
    Keyboard.enableRepeatEvents( true );

    int x = ( width - xSize ) / 2;
    int y = ( height - ySize ) / 2;
    m_energizeButton = new GuiButton( BUTTON_ENERGIZE, x + 8, y + 8, xSize - 16, 20, "" );
    m_energizeButton2 = new GuiButton( BUTTON_ENERGIZE, x + 8, y + 8 + 8 + 20 + 6 + 20 + 6, xSize - 16, 20, "" );

    m_localPortalIDField = new GuiTextField( fontRendererObj, x + 9, y - 20, xSize - 18, 20 );
    m_localPortalIDField.setFocused( false );
    m_localPortalIDField.setMaxStringLength( 32 );
    m_localPortalIDField.setText( encodeOptionalText( m_computer.getPortalID() ) );

    m_destinationPortalIDField = new GuiTextField( fontRendererObj, x + 9, y + 8 + 8,  xSize - 18, 20 );
    m_destinationPortalIDField.setFocused( false );
    m_destinationPortalIDField.setMaxStringLength( 32 );
    m_destinationPortalIDField.setText( encodeOptionalText( m_computer.getRemotePortalID() ) );

    m_changeServerButton = new GuiButton( BUTTON_CYCLE_SERVERS, x + 8, y + 8 + 8 + 20 + 6, xSize - 16 - 16 - 3 - 16 - 3, 20, "" );
    m_addServerButton = new GuiButton( BUTTON_ADD_SERVER, x + xSize - 8 - 16 - 3 - 16, y + 8 + 8 + 20 + 6, 16, 20, "+" );
    m_removeServerButton =  new GuiButton( BUTTON_REMOVE_SERVER, x + xSize - 8 - 16, y + 8 + 8 + 20 + 6, 16, 20, "-" );
    m_confirmAddServerButton = new GuiButton( BUTTON_CONFIRM_ADD_SERVER, x + xSize - 8 - 35, y + 8 + 8 + 20 + 6, 35, 20, I18n.format( "gui.qcraft:computer.ok" ) );

    m_newServerAddressField = new GuiTextField( fontRendererObj, x + 9, y + 8 + 8 + 20 + 7, xSize - 18 - 35 - 3, 18 );
    m_newServerAddressField.setFocused( false );
    m_newServerAddressField.setMaxStringLength( 64 );
    m_newServerAddressField.setText( encodeOptionalText( m_computer.getRemoteServerAddress() ) );

    updateStatus();
}
 
Example 9
Source File: GuiSpaceLaser.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void initGui() {
	super.initGui();

	int x = (width - xSize) / 2;
	int y = (height - ySize) / 2;

	//Create and setup the textboxes
	xbox = new GuiTextField(0,this.fontRenderer, x + 113, y + 31, 50, 10);
	ybox = new GuiTextField(1,this.fontRenderer, x + 113, y + 41, 50, 10);
	xbox.setMaxStringLength(15);
	xbox.setEnableBackgroundDrawing(true);
	xbox.setFocused(true);
	xbox.setCanLoseFocus(true);
	xbox.setEnabled(true);
	ybox.setMaxStringLength(15);
	ybox.setEnableBackgroundDrawing(true);
	ybox.setFocused(false);
	ybox.setCanLoseFocus(true);
	ybox.setEnabled(true);

	modeDown = new GuiImageButton(0, x + 103, y + 20, 5, 8, zmaster587.libVulpes.inventory.TextureResources.buttonLeft);
	modeUp = new GuiImageButton(1, x + 157, y + 20, 5, 8,  zmaster587.libVulpes.inventory.TextureResources.buttonRight);
	this.buttonList.add(modeUp);
	this.buttonList.add(modeDown);
	this.buttonList.add(new GuiButton(2, x + 103, y + 62, 34,20, "Reset"));
}
 
Example 10
Source File: GuiCamoMine.java    From AdvancedMod with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void initGui(){
    super.initGui();
    resetButton = new GuiButton(0, guiLeft + 10, guiTop + 37, 40, 20, "");
    buttonList.add(resetButton);

    textField = new GuiTextField(fontRendererObj, guiLeft + 100, guiTop + 65, 70, 12);
    textField.setMaxStringLength(40);
    textField.setText(te.getTarget());
}
 
Example 11
Source File: GuiHelm.java    From archimedes-ships with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void initGui()
{
	super.initGui();
	
	Keyboard.enableRepeatEvents(true);
	
	int btnx = guiLeft - 100;
	int btny = guiTop + 20;
	buttonList.clear();
	
	btnRename = new GuiButton(4, btnx, btny, 100, 20, StatCollector.translateToLocal("gui.shipstatus.rename"));
	buttonList.add(btnRename);
	
	btnAssemble = new GuiButton(1, btnx, btny += 20, 100, 20, StatCollector.translateToLocal("gui.shipstatus.compile"));
	buttonList.add(btnAssemble);
	
	btnUndo = new GuiButton(2, btnx, btny += 20, 100, 20, StatCollector.translateToLocal("gui.shipstatus.undo"));
	btnUndo.enabled = tileEntity.getPrevAssembleResult() != null && tileEntity.getPrevAssembleResult().getCode() != AssembleResult.RESULT_NONE;
	buttonList.add(btnUndo);
	
	btnMount = new GuiButton(3, btnx, btny += 20, 100, 20, StatCollector.translateToLocal("gui.shipstatus.mount"));
	btnMount.enabled = tileEntity.getAssembleResult() != null && tileEntity.getAssembleResult().getCode() == AssembleResult.RESULT_OK;
	buttonList.add(btnMount);
	
	txtShipName = new GuiTextField(fontRendererObj, guiLeft + 8 + xSize / 2, guiTop + 21, 120, 10);
	txtShipName.setMaxStringLength(127);
	txtShipName.setEnableBackgroundDrawing(false);
	txtShipName.setVisible(true);
	txtShipName.setCanLoseFocus(false);
	txtShipName.setTextColor(0xFFFFFF);
	txtShipName.setText(tileEntity.getShipInfo().shipName);
}
 
Example 12
Source File: GuiSearcher.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds the buttons (and other controls) to the screen in question.
 */
@Override
public void initGui(){
    super.initGui();
    buttonList.clear();
    Keyboard.enableRepeatEvents(true);
    searchField = new GuiTextField(fontRendererObj, guiLeft + 20, guiTop + 36, 89, fontRendererObj.FONT_HEIGHT);
    searchField.setMaxStringLength(15);
    searchField.setEnableBackgroundDrawing(true);
    searchField.setVisible(true);
    searchField.setFocused(true);
    searchField.setTextColor(16777215);

    updateCreativeSearch();
}
 
Example 13
Source File: ButtonInputFieldWrapper.java    From SkyblockAddons with MIT License 5 votes vote down vote up
public ButtonInputFieldWrapper(int x, int y, int w, int h, String buttonText, String placeholderText, int maxLength, boolean focused, UpdateCallback<String> textUpdated) {
    super(-1, x, y, buttonText);
    this.placeholderText = placeholderText;
    this.textUpdated = textUpdated;

    textField = new GuiTextField(-1, Minecraft.getMinecraft().fontRendererObj, x, y, w, h);
    textField.setMaxStringLength(maxLength);
    textField.setFocused(focused);
    textField.setText(buttonText);
}
 
Example 14
Source File: HyperiumGuiChat.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void init(GuiTextField inputField) {
    inputField.setMaxStringLength(HypixelDetector.getInstance().isHypixel() ? 256 : 100);
}
 
Example 15
Source File: GuiAltManager.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
public void initGui() {
    int textFieldWidth = Math.max(width / 8, 70);

    searchField = new GuiTextField(2, Fonts.font40, width - textFieldWidth - 10, 10, textFieldWidth, 20);
    searchField.setMaxStringLength(Integer.MAX_VALUE);

    altsList = new GuiList(this);
    altsList.registerScrollButtons(7, 8);

    int index = -1;

    for (int i = 0; i < LiquidBounce.fileManager.accountsConfig.getAccounts().size(); i++) {
        MinecraftAccount minecraftAccount = LiquidBounce.fileManager.accountsConfig.getAccounts().get(i);

        if (minecraftAccount != null && (((minecraftAccount.getPassword() == null || minecraftAccount.getPassword().isEmpty()) && minecraftAccount.getName() != null && minecraftAccount.getName().equals(mc.session.getUsername())) || minecraftAccount.getAccountName() != null && minecraftAccount.getAccountName().equals(mc.session.getUsername()))) {
            index = i;
            break;
        }
    }

    altsList.elementClicked(index, false, 0, 0);
    altsList.scrollBy(index * altsList.slotHeight);

    int j = 22;
    this.buttonList.add(new GuiButton(1, width - 80, j + 24, 70, 20, "Add"));
    this.buttonList.add(new GuiButton(2, width - 80, j + 24 * 2, 70, 20, "Remove"));
    this.buttonList.add(new GuiButton(7, width - 80, j + 24 * 3, 70, 20, "Import"));
    this.buttonList.add(new GuiButton(12, width - 80, j + 24 * 4, 70, 20, "Export"));
    this.buttonList.add(new GuiButton(8, width - 80, j + 24 * 5, 70, 20, "Copy"));

    this.buttonList.add(new GuiButton(0, width - 80, height - 65, 70, 20, "Back"));

    this.buttonList.add(loginButton = new GuiButton(3, 5, j + 24, 90, 20, "Login"));
    this.buttonList.add(randomButton = new GuiButton(4, 5, j + 24 * 2, 90, 20, "Random"));
    this.buttonList.add(new GuiButton(6, 5, j + 24 * 3, 90, 20, "Direct Login"));
    this.buttonList.add(new GuiButton(88, 5, j + 24 * 4, 90, 20, "Change Name"));

    if (GENERATORS.getOrDefault("mcleaks", true))
        this.buttonList.add(new GuiButton(5, 5, j + 24 * 5 + 5, 90, 20, "MCLeaks"));
    if (GENERATORS.getOrDefault("thealtening", true))
        this.buttonList.add(new GuiButton(9, 5, j + 24 * 6 + 5, 90, 20, "TheAltening"));

    this.buttonList.add(new GuiButton(10, 5, j + 24 * 7 + 5, 90, 20, "Session Login"));
    this.buttonList.add(new GuiButton(11, 5, j + 24 * 8 + 10, 90, 20, "Cape"));

}
 
Example 16
Source File: GuiReactorControlRod.java    From BigReactors with MIT License 4 votes vote down vote up
@Override
public void initGui() {
	super.initGui();

	int leftX = guiLeft + 4;
	int topY = guiTop + 4;
	
	Keyboard.enableRepeatEvents(true);
	
	titleString = new BeefGuiLabel(this, "Reactor Control Rod", leftX, topY);
	topY += titleString.getHeight() + 8;
	
	rodNameLabel = new BeefGuiLabel(this, "Name:", leftX, topY + 6);
	
	rodName = new GuiTextField(fontRendererObj, leftX + 4 + rodNameLabel.getWidth(), topY, 100, 20);
	rodName.setCanLoseFocus(true);
	rodName.setMaxStringLength(32);
	rodName.setText(entity.getName());
	rodName.setEnabled(true);
	
	setNameBtn = new GuiButton(2, guiLeft + 140, topY, 30, 20, "Set");
	setNameBtn.enabled = false;
	topY += 28;
	
	rodInsertIcon = new BeefGuiIcon(this, leftX+42, topY, 16, 16, ClientProxy.GuiIcons.getIcon("controlRod"), new String[] { EnumChatFormatting.AQUA + "Rod Insertion", "", "Change the control rod's insertion.", "Higher insertion slows reaction rate.", "", "Lower reaction rates reduce heat,", "energy, radiation output, and", "fuel consumption." });
	insertionLabel = new BeefGuiLabel(this, "", leftX+62, topY+5);
	topY += 20;
	insertionBar = new BeefGuiInsertionProgressBar(this, leftX+40, topY);

	topY += 12;
	rodRetractBtn = new GuiIconButton(0, leftX+70, topY, 20, 20, ClientProxy.GuiIcons.getIcon("upArrow"), new String[] { EnumChatFormatting.AQUA + "Insert Rod", "Increase insertion by 10.", "", "Shift: +100", "Alt: +5", "Shift+Alt: +1", "", "Ctrl: Change ALL Rods" });
	topY += 20;
	rodInsertBtn = new GuiIconButton(1, leftX+70, topY, 20, 20, ClientProxy.GuiIcons.getIcon("downArrow"), new String[] { EnumChatFormatting.AQUA + "Retract Rod", "Reduce insertion by 10.", "", "Shift: -100", "Alt: -5", "Shift+Alt: -1", "", "Ctrl: Change ALL Rods" });
	topY += 32;

	registerControl(insertionBar);
	registerControl(titleString);
	registerControl(rodNameLabel);
	registerControl(rodInsertIcon);
	registerControl(insertionLabel);

	registerControl(rodName);
	registerControl(rodRetractBtn);
	registerControl(rodInsertBtn);
	registerControl(setNameBtn);
	
	updateStrings();
}
 
Example 17
Source File: GuiTerminalFluid.java    From ExtraCells1 with MIT License 4 votes vote down vote up
@Override
public void initGui()
{
	super.initGui();
	fluidWidgets = new ArrayList<AbstractFluidWidget>();
	Mouse.getDWheel();

	List<Fluid> selectorFluids = new ArrayList<Fluid>();
	for (SpecialFluidStack stack : oldFluids)
	{
		fluidWidgets.add(new WidgetFluidSelector(this, stack));
		selectorFluids.add(stack.getFluidStack().getFluid());
	}
	for (Fluid fluid : oldCraftables)
		if (!selectorFluids.contains(fluid))
			fluidWidgets.add(new WidgetFluidRequest(this, fluid));

	for (AbstractFluidWidget widget : fluidWidgets)
	{
		if (widget instanceof WidgetFluidSelector && widget.getFluid() == oldSelected)
		{
			WidgetFluidSelector selector = (WidgetFluidSelector) widget;
			selector.setSelected(true);
			updateSelected(selector);
		}
	}
	Collections.sort(fluidWidgets, new FluidWidgetComparator());
	searchbar = new GuiTextField(fontRenderer, guiLeft + 81, guiTop - 12, 88, 10)
	{
		private int xPos = 0;
		private int yPos = 0;
		private int width = 0;
		private int height = 0;

		public void mouseClicked(int x, int y, int mouseBtn)
		{
			boolean flag = x >= xPos && x < xPos + width && y >= yPos && y < yPos + height;
			if (flag && mouseBtn == 3)
				setText("");
		}
	};
	searchbar.setEnableBackgroundDrawing(false);
	searchbar.setFocused(true);
	searchbar.setMaxStringLength(15);
}