From the MySQL Database Manager, we can generate windows for insert, update, delete and data display quickly on TetrisIDE.
But, we will learn to do the manual way to pratice and rich our knowledge.
We will build a program with three windows: main window, product inserction and product query.
Create a project named ProductRegistration and change the Title of the JFrameMain to Product.
Add two buttons and change the Title of each one to Insert and Query. Change the property Icon and select an image (your choice).
On the MySQL Database Manager, in the left sidebar, insert a table named product with the columns:
id int not null primary key, description varchar(50), price decimal(9, 2)
Create a window, clicking with the right mouse button on Window Explorer and selecting New, with the name JDialogInsert and change the Title to Insert and Window to Dialog (Object Inspector). Add two Labels, with Text Description and Price, two TextFields, with names jTextFieldDescription and jTextFieldPrice, and a Button with Text Insert. Change the HorizontalTextAlignment of jTextFieldPrice to RIGHT and Mask to Decimal.
Select the button Insert and perform double click in the OnClick event, on Object Inspector.
Add the function insertRecord with the parameters:
Add a function closeWindow too, without parameters.
Create another window with name JDialogQuery and change the Title to Query and Window to Dialog (Object Inspector).
Add a Table and change the name to jTableProduct.
Insert the text below on properties Columns and Titles:
Add the function fillTable to the OnShow event of the window with the parameters:
id, description, price
order by id
Go back to the JFrameMain and add the function openWindow, on button Insert, in the OnClick event with the parameter:
Add to the OnClick event of the button Query too with te parameter:
Save and Run the application, clicking on the buttons in the Toolbar ou typing CTRL + S and F9.