Graphic User Interface

 Graphic User Interface (GUI) is also known as a FORM, where you design a user interface for a user by drag and drop controls on your frame from your Palette.


 let start 

 Create a project and give it a name 

 uncheck the main class name and click finish. 

 To add a form, right click the package name in the Projects window. Select New > JFrame Form from the menu.

Give it a class package name. Click the Finish button to complete the process. This will apply on your netbeans windows. Run the form your just create. 

This is how your form interface will look like for now.

 NOTE: When the palette is missing you can add it back by clicking Windows > IDE Tools > palette/ any other tools missing from the NetBeans menu. Also, if you want your GUI to maintain a specific shape. Click on it, go to the properties tab and uncheck resizable

Once you select the form panel by clicking on it, you will notice a palete panel showing different form elements. Click on each one and add to your form one after the other depending on what you design you intend achieving at the end of the day. To set properties, either you resize the inputs or you select a particular one and change the property. The property panel is located at the right side of your editor just like the palette.

In programming terms, an event is when something special happens. For forms, this means things like buttons being clicked, the mouse moving, text being entered into text fields, the programming closing Events are objects in Java. They come from a series of classes stored in java.util.EvenObject.

Let’s try to get a number and make it show in the textField, we will use button 1 as a case study. 

Step 1: Use the getText() method to get the number once the button is clicked. Example: String one = jButton1.getText(); Note: jButton1 is the variable name of Button 1. 

Step 2: Having gotten the value, we need to make show on the textField. To achieve that we use setText() method Example: displayBox.setText(one); Note: displayBox is the variable name of the textField which serves as our display board.

NB: Next Article will be talking about  Addition Button in Java.

Share to your friends and comment below

Written by Pascal Okorie

Post a Comment