hey, I made a mod that open a GUI with button in it but i don't want the classic gray button of minecraft I want my button look like this but i don't find the code for making that possible.
Create a new class and call it whatever you want. For this example, I'm calling it YourClassName. It would look like this.
public class YourClassName extends GuiButton {
//Code goes here
}
In the //Code goes here, you could probably copy the GUIButton code and paste it, and edit some of the code to make it blue. Someone correct me if I'm wrong about this.
So when you make the button for your GUI like this...
GuiButton button = new GuiBUtton(...)
you would instead use your above class name, because you created your own button object.
YourClassName button = new YourClassName(...)
I'm pretty sure that's what Caagr98 is talking about. I could be wrong though.
Create your class that extends GuiButton (or else when you add your button to the controlList it will throw a java.lang.ClassCastException because it tries to cast your button to GuiButton)
Override drawButton().
Copy the drawButton method from GuiButton.
Bind your image to the renderEngine.
You see where it says drawTexturedModalRect()? That's where it's drawn. The arguments are:
If you have any questions or want some sample code, feel free to ask.
Rollback Post to RevisionRollBack
“Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.”
- Linus Torvalds (Finnish American, software engineer and hacker, principal force behind the development of the Linux kernel)
Thanks but this is the first thing I tried before post this topic but I get a implicit super constructor error when extends to GuiButton, so can you send me a example that will really help
Thanks but this is the first thing I tried before post this topic but I get a implicit super constructor error when extends to GuiButton, so can you send me a example that will really help
You need to call "super(GuiButton constructor requirements here);" on the first line of your constructor.
“Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.”
- Linus Torvalds (Finnish American, software engineer and hacker, principal force behind the development of the Linux kernel)
thanks for help!
In the //Code goes here, you could probably copy the GUIButton code and paste it, and edit some of the code to make it blue. Someone correct me if I'm wrong about this.
So when you make the button for your GUI like this...
you would instead use your above class name, because you created your own button object.
I'm pretty sure that's what Caagr98 is talking about. I could be wrong though.
Create your class that extends GuiButton (or else when you add your button to the controlList it will throw a java.lang.ClassCastException because it tries to cast your button to GuiButton)
Override drawButton().
Copy the drawButton method from GuiButton.
Bind your image to the renderEngine.
You see where it says drawTexturedModalRect()? That's where it's drawn. The arguments are:
If you have any questions or want some sample code, feel free to ask.
- Linus Torvalds (Finnish American, software engineer and hacker, principal force behind the development of the Linux kernel)
You need to call "super(GuiButton constructor requirements here);" on the first line of your constructor.
- Linus Torvalds (Finnish American, software engineer and hacker, principal force behind the development of the Linux kernel)
and for the custom button I edit this line ?
I got it work with that code thank you all!! the only problem now is that the images are not centered and not the good dimmensions
Jep, did you understand GL graphics before doing this?