Creating a GUI: Buttons and Menu bars

Creating a basic menu bar in the GUI
Drawing it

First, we need to find the width and the height of our screen. I am currently using 320,200 as my size.

Second, we need to get x and y to set it in.

Finally, we need to SET the pixels

and there we go, we just made a rectangle at the bottom of the screen.

Mouse Handling

When creating buttons in your GUI, you’ll want to check whether the Mouse’s X or Y coordinates are inside the area of the rectangle whilst the mouse button was pressed. This simple snippet can be used to perform this check. If the mouse button is pressed and if its coordinates are inside the rectangle’s area, then it will perform the function specified.
(ifMouseClicked();)

In this example, there is no need to check the X coordinate, but you may want to in your Operating System’s GUI.