Jump to content

Update text on gui


Recommended Posts

I want to update the text on my gui when the "+" button is pressed


heres the gui code

package com.mcpixelplex.Gui;

import org.lwjgl.opengl.GL11;

import com.mcpixelplex.lib.RefStrings;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;

public class TestGui extends GuiScreen {

Minecraft mc = Minecraft.getMinecraft();

GuiButton testButton;

public String[] levelDisplay = new String[]{"1","2","3","4","5","6","7","8","9","10"};
public int level = 0;

public final int xSizeOfTexture = 256;
public final int ySizeOfTexture = 156;

public TestGui(EntityPlayer player){


public void drawScreen(int x, int y, float f){

	int posX = (this.width - xSizeOfTexture) / 2;
	int posY = (this.height - ySizeOfTexture) / 2;

	GL11.glColor4f(1F, 1F, 1F, 1F);
	mc.renderEngine.bindTexture(new ResourceLocation(RefStrings.MODID, "/textures/gui/background.png"));

	drawTexturedModalRect(posX, posY, 0, 0, xSizeOfTexture, ySizeOfTexture);

	fontRendererObj.drawString("XP Block", posX + 20, posY + 5, 0x000000);		
	fontRendererObj.drawString(levelDisplay[level], xSizeOfTexture / 2, ySizeOfTexture / 2, 0x000000);	

	super.drawScreen(x, y, f);


public void initGui(){

	int xSize = 100;
	int ySize = 20;

	int posX = (xSizeOfTexture) / 2;
	int posY = (ySizeOfTexture) / 2;

	int bottomButton = (ySizeOfTexture - ySize - 2);

	buttonList.add(new GuiButton(0, posX + 40, bottomButton + 40, 100, 20, "no use"));
	buttonList.add(new GuiButton(1, posX + 40, posY + 40, 20, 20, "+"));


public void actionPreformed(GuiButton button){
	case 0:
	case 1:
		if(level == 10){


public boolean doesGuiPauseGame(){
	return false;


Link to comment
Share on other sites

Spelling mistake on actionPerformed method your wrote "actionPreformed", should be Performed :P



P.S. This does not relate with your problem but, the super.initGui call is useless in the initGuid() method as it's super implementation has no body ;)

I require Java, both the coffee and the code :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.