![]() ![]() For this, we will use a method called getText(). Let’s write code to read the input given by the user in jTextField1. ![]() These blocks are protected and uneditable. ![]() Notice that the NetBeans Builder automatically generates sections of code in gray areas, called Guarded Blocks. The source code window will open with the cursor placed at the point where we have to write the code. Since the Calculate button will perform the action, double-click on it. When the user enters the value of side in jTextField1 and clicks the Calculate button, the area of the square should be displayed in jTextField2. The application will close when you click it. Clicking this button will remove the text in jTextField1 and jTextField2 previously entered by the user. When you click it, jTextField2 will display the area of the square. JButton1: This will be the Calculate button. JLabel3 (Area of Square Calculator): This will be the title label of the form. JLabel2 (Area): This will be the label for jTextField2. We should make this text field uneditable. JTextField2: This is the text field where the area will be displayed. JLabel1 (Side): This will be the label for jTextField1. JTextField1: This is the text field where the user will enter the value for side of the square. Let’s see the use of the components in the form. The other way to edit text is to right-click on the component and select Edit Text.Īlways keep the text fields empty so that the user can directly enter the values. You can arrange and resize the components as well as the frame however you want but, the arrangement should be logical and easily understandable by the user.Ĭhanging the properties of the components: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |