Chat Tutorial in NetBeans/GUI Client: Difference between revisions
Content deleted Content added
imported>SimonSmall Added page for GUI client |
imported>SimonSmall Tidy up |
||
| (7 intermediate revisions by the same user not shown) | |||
Line 1:
= Introduction =
These instructions are a continuation
= NetBeans Project =
Open the
Right click on the client package and select
Delete the '''Test.java''' entry (right click, select delete).
The following files need to be created.
Line 19:
<source lang="Java">
/*
*
*/
package client;
Line 36:
</source>
Ignore errors for the moment (we have not defined the '''View''' object).
== View.java (part 1) ==
Line 42:
This may appear to be a bit messy, as we are combining manual file editing with the automatic GUI generation method. Please take care to follow the instructions carefully.
Right-click on the '''client package''' and
Click the '''Source''' button on the top of the editor window. Modify the class line so that it shows '''...extends JFrame implements ActionListener'''. The top of the code should now be:
<source lang="Java">
/*
*
*/
Line 81 ⟶ 78:
</source>
The last line is shown as a box of '''"Generated Code"''', which can be expanded using the + on the left but MUST NOT be changed in this screen, only in the GUI editor. Delete the code belonging to the '''main''' method, up to the line showing the '''Variables
The rest of the code should now be:
Line 91 ⟶ 88:
</source>
If you have edited this correctly, you can save the file, close it and open it again. It will still show as the form you had before. If you look at the files it has created, using the files explorer, there is a '''View.java''' and a '''View.form''' and these two files must be consistent for the View class to show correctly in NetBeans. If it does not, delete the View class and start again; it is too difficult to try to edit both files manually.
== GUI Form ==
Line 97 ⟶ 94:
Add the following components to the GUI form. Note that the sizes given are suggestions; feel free to experiment with sizes and positions.
* Click on the blank window. In the '''Properties''' list, change
* Add a '''Label''' from the
* Add a second label (select and drag) below the first. Change the '''text''' to '''Password'''.
* Add a third label (select and drag) below the second. Change the '''text''' to '''eMail'''.
* Add a '''Text Field''' ('''Palette''', '''Swing Controls''' section), to the right of the Username label. In the '''Code''' list change
* Add a second Text Field below the first field and to the right of the Password label. In the '''Code''' list change
* Add a third Text Field below the second field. In the '''Code''' list change
* Add a '''Button''' ('''Swing Controls''' section) below these fields, aligned to the right. In the '''Code''' list change
* Add a '''Scroll Pane''' ('''Swing Containers''') positioned below the previous elements. Scroll down the '''Properties''' list and change
* Add a '''Text Area''' (Controls), dragged into the Scroll Pane. In the '''Code''' list change
* Add a '''Text Field''' (Controls), below the Text Area. In the '''Code''' list change
* Add a '''Button''' (Controls) to the right of the Text Field. In the '''Code''' list change
Note that the shaded window area may resize as you add these elements; you can drag this to a larger size if it makes adding elements easier, then drag it to nicely surround the elements when you have finished.
Line 125 ⟶ 122:
== View.java (part 2) ==
Click the '''Source''' button. Below the class definition line, add the following code to create the action controls for the form. Note the the first and last lines already exist.
<source lang="Java">
Line 199 ⟶ 196:
== Client.java ==
The '''Client.java''' file that existed previously is used in this part of the tutorial. It remains the same.
== Building ==
If there are no errors in the package, select '''Run''', '''Build Project''' from the NetBeans menu bar. This will create '''client.jar''' in the '''dist''' directory. That file is required for the deployment.
[[Category: NetBeans]]
| |||