I posted the other day in Graphics and Therory forum and I don't think I phrased my question right. Maybe this is more of a beginners question anyways. I want to make a UI for a game. My game uses a game loop that calls update and render methods. So as of right now I am making a button class that implement MouseListener/ MouseMotionListener.

These buttons are very basic they have:

-Rectangle2D for the button its self

-they have a boolean called "hover" that is set to true if the mouse is contained in that Rectangle2D

-they have a render method to render it to the screen

There is a bit more code and I am simplifiing the process a bit, but am I on the right track or should I be doing something different.

Sorry Lysy what I want to know is am I doing what you would do to create components for a UI on a game that uses a loop for updating and rendering objects to the screen. Is there another way to make UI's for this type of game since the screen is getting redrawn 60 times a second or whatever I have it limited to. I just want to know the correct way to do it.

Sorry Lysy what I want to know is am I doing what you would do to create components for a UI on a game that uses a loop for updating and rendering objects to the screen. Is there another way to make UI's for this type of game since the screen is getting redrawn 60 times a second or whatever I have it limited to. I just want to know the correct way to do it.

Yeah, you're doing it right. All the elements that render on screen should be called in a game loop. I think you should also do some research on 'state machines'. You will be able to create menu, game screen and many others, and your code will stay clear and will attract females.