Welcome to another lesson in java programing , In this session we will create a personal wallet manager. In the previous lesson we got to set our environment ,if you missed please check the previous video to catch up.

We can start by quoting Maya Angelou she says “A Bird does not sing because it has an answer, it sings because it has a song”.

If your environment is set we can get the NetBeans running and start coding. Lets create our first project.

The easiest way start development is to have an IDE such as NetBeans which helps simple UI just by dragging and dropping objects.


First: Create a new project, choose Java with Maven for the category & Java Application for the project click -> Next to a following step you can leave the default settings then click ->Finish

Second: In the new project, create a file, choose Swing GUI Forms for category and JFrame Form for file type. Click -> Next then Finish. This will create for you a NewJFrame class with source and an empty design.

To add component, select it on the palette.

For our simple application we’ll add:

  • 5 Labels for: ‘Personal Wallet’ , ‘Item’, ‘Quantity’, ‘Price’, and one more for displaying total.
  • 3 Text Fields for ‘Item’, ‘Quantity’, and ‘Price’ labels.
  • 1 Text Areas to list items
  • 1 Button for computing total price for each ‘Item’

Hit run green button at the top

To add more life to this application lets do some code . Right click on button compute Go to events ->Action -> Action Performed this will take you to a window containing source code , find a method jButton1ActionPerformed we will write our code here . At the very bottom we have our drag and drop components

Add the code below and hit run then use your application to compute

`jTextField1.getText(); ` we simply get text from our text field and store the final value in a string variable.

Then assuming our quantity and price are integers we simply Use `Integer( ) ` class to wrap our string
values and make them Integers ,` Total = qnty*new_price; ` finally we multiply the quantity and price
and display it in our Text area and Total Label

Check out our YouTube channel

Final word: “You cannot achieve competence(much less perfection) without practice.” See you on our next lesson.

Start typing and press Enter to search

Shopping Cart