Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I want to display a few paragraphs of text which will have all the changes in an upcoming version. But if the user has their window size different to what I'm testing with then it will go over the edges and the user will not view it correctly.

How would I implement a scroll bar and format it to fit in every window of any size?

 

Heres what I have now:

package mc.ayyyylmao.testgui;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiControls;
import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiScreen;

public class TestGui extends GuiScreen {
private GuiScreen parentScreen;

private GuiButton dlnow;
private GuiButton rmlater;

private int headerPos;
private int footerPos;

private byte byte0 = -16;

public TestGui(GuiScreen parent) {
	this.parentScreen = parent;
}

public void initGui() {
	this.buttonList.clear();

	headerPos = 35;
	footerPos = this.height - 29;

	this.dlnow = new GuiButton(1, this.width / 2 - 70, footerPos-17, 150, 20, "Download Now");
	this.rmlater = new GuiButton(2, this.width / 2 - 70, footerPos+3, 150, 20, "Remind Me Later");

	this.buttonList.add(dlnow);
	this.buttonList.add(rmlater);
}

    protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
        if (mouseButton == 0) {
            for (int l = 0; l < this.buttonList.size(); ++l) {
                GuiButton guibutton = (GuiButton)this.buttonList.get(l);

                if (guibutton.mousePressed(this.mc, mouseX, mouseY)) {
                    actionPerformed(guibutton);
                }
            }
        }
    }

protected void actionPerformed(GuiButton button) {
	switch(button.id) {		
		case 1:
                                // Do stuff
			break;
                        case 2:
                                // Do stuff
                                break;
	}
}

public void drawScreen(int mouseX, int mouseY, float partialTicks) {	
	this.drawBackground(0);
	this.drawGradientRect(0, 50, this.width, this.height - 50, -1072689136, -804253680);

	this.drawCenteredString(this.fontRendererObj, "New Version Released", this.width/2, headerPos, 0xFFFFFF);

	super.drawScreen(mouseX, mouseY, partialTicks);
}
}

 

Thanks.

  • Author

Use FontRenderer#drawSplitString and it will split the string so that it fits on screen.

And what about the height of the window?

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.