Jump to content

Recommended Posts

Posted

Hi.

 

I'm making a combination lock, for which I've made a gui which displays the numbers 0-9. The only problem that I've run into so far is that I can't seem to change the width of the actual buttons. from trial and error, I realised that the width and height parameters of the GuiButton method are the positions of the button in the GUI.

 

Does anyone know how to change the width of the button itself?

 

Here's the relevant GUI code:

 

package vivadaylight3.interlock.tileentities.numpadblock;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.util.StringTranslate;

import org.lwjgl.input.Keyboard;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiNumpadBlock extends GuiScreen
{

    /** Combination and set/clear buttons. */
    private final TileEntityNumpadBlock numpadBlock;
    private GuiButton button1;
    private GuiButton button2;
    private GuiButton button3;
    private GuiButton button4;
    private GuiButton button5;
    private GuiButton button6;
    private GuiButton button7;
    private GuiButton button8;
    private GuiButton button9;
    private GuiButton button0;
    private GuiButton buttonClear;
    private GuiButton buttonSet;
   // private EntityPlayer player;

    public GuiNumpadBlock(TileEntityNumpadBlock par1)
    {
        this.numpadBlock = par1;
        //this.player = par2Player;
      //  this.player.addChatMessage("GuiNUmpad: constructor");
    }

    /**
     * Called from the main game loop to update the screen.
     */
    public void updateScreen()
    {
        //this.enteredCodeField.updateCursorCounter();
       // this.player.addChatMessage("GuiNUmpad: updateScreen");
    }

    /**
     * Adds the buttons (and other controls) to the screen in question.
     */
    public void initGui()
    {
        StringTranslate stringtranslate = StringTranslate.getInstance();
        Keyboard.enableRepeatEvents(true);
        this.buttonList.clear();
        this.buttonList.add(this.button1 = new GuiButton(1, this.width / 2 - 150, 47, "1"));
        this.buttonList.add(this.button2 = new GuiButton(2, this.width / 2 - 150, 70, "2"));
        this.buttonList.add(this.button3 = new GuiButton(3, this.width / 2 - 150, 93, "3"));
        this.buttonList.add(this.button4 = new GuiButton(4, this.width / 2 - 150, 116, "4"));
        this.buttonList.add(this.button5 = new GuiButton(5, this.width / 2 - 150, 139, "5"));
        this.buttonList.add(this.button6 = new GuiButton(6, this.width / 2 - 150, 162, "6"));
        this.buttonList.add(this.button7 = new GuiButton(7, this.width / 2 - 150, 185, "7"));
       // this.player.addChatMessage("GuiNUmpad: initGui");
    }

 

A screenshot of how it is now, I'd like to be able to create 3 rows of 3 buttons each + an additional button under 9 for the number 0.

 

width=800 height=449http://i1059.photobucket.com/albums/t425/CascadeRP/2013-05-18_210731_zps3af34c36.png[/img]

"Thinking that coding is the nerdy IT guy at work rebooting your computer is like thinking that music is what happens when the piano tuner comes round." - Ed Rex

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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