代写C C++ Java Python 视频讲解客服在线客服在线

代做国外C C++ Java程序 Python QQ 2365427650 Email 2365427650@qq.com 免费咨询编程问题

« MIPS FILE IOClient and Server code »

Swing Chat GUI

Purpose: Building the GUIs
The purpose is to build a multi-threaded client/server chat application.
In Part 1 of the assignment you are to build the GUI. In Part 2 of the assignment you
are to write the client and the server code.
Problem Specification:
In this part of Assignment #2 you are to build a relatively simple GUI for the client and
server part application. You may use the Swing API or JavaFX API to build the GUI.
Your GUI must have exactly the same appearance (including the sizes of the
components) as the one shown in the figures below.
Important note: If you decide to use GUI builders to build the GUI, you may not be
able the implement the Part 2 of the assignment.
Swing GUI
Fig. 1.
The Client Swing GUI at launch.
CST – JAP, Assignment 2, Part 1, MMXX       Page 2 of 11
Fig. 2. The Client Swing GUI with Combo Box opened.
Requirements for the Client Swing GUI:
The size of the non-resizable frame is (588, 500). At launch the location of the
frame must be set by the platform.
The combo box and the Connect button must have the same size visually.
The text fields and the combo box must have white backgrounds and must be
editable. The displayed text must be left aligned.
The preferred size of the Host: label is (35,30) and the Port: label is (35,30).
All buttons must have mnemonics.
The Send button must be disabled at launch and must have the same height as
the adjacent text field. The text field must display the specified text at launch.
The labels must have mnemonics and when the corresponding Alt-Key is
pressed the focus must be transferred to the corresponding host text field or the
port combo box.
At launch the host text field must has the focus and (the insertion caret (cursor))
must be blinking at the beginning of the text field in front of the latter
l of the text
localhost. The text (localhost) in the host text field must be 5 pixels removed from
the left margin of the text field.
The CONNECTION panel must have a 10 pixels red titled line border with
centered title.
The MESSAGE panel must have a 10 pixels blue titled line border.
The CHAT DISPLAY panel must have a 10 pixels black titled line border with
centered title.

CST – JAP, Assignment 2, Part 1, MMXX       Page 3 of 11
The CHAT DISPLAY text area must have 30 rows and 45 columns. The text area
must have horizontal and vertical scroll bars. Only the vertical scroll bar must be
visible at launch. The horizontal scroll bar is not visible at launch but must
become visible if the displayed text exceeds the number of columns displayed.
The text area must not be editable.
The Host label, the Port label and the left margin of the message text field must
be visibly vertically aligned. The right margin of the host text field and the right
margin of the Send button must be visibly vertically aligned. The left margin of
the combo box and left margin of the host text field must be visibly vertically
aligned.
Replace my name in the frame title with your name.
No event handling is required for this part of the assignment.
Fig. 3. The Server Swing GUI at launch.
CST – JAP, Assignment 2, Part 1, MMXX       Page 4 of 11
Requirements for the Server Swing GUI:
The size of the non-resizable frame is (588, 500). At launch the location of the
frame must be in the center of the screen.
The Send button must not be disabled at launch and must have the same height
as the adjacent text field. It must have a mnemonic.
The text field must display the specified text at launch. At launch the text field
must has the focus and (the insertion caret (cursor) must be blinking at the
beginning of the text field. The text field must be editable.
The MESSAGE panel must have a 10 pixels blue titled line border.
The CHAT DISPLAY panel must have a 10 pixels black titled line border with
centered title.
The CHAT DISPLAY text area must have 30 rows and 45 columns. The text area
must have horizontal and vertical scroll bars. Only the vertical scroll bar must be
visible at launch. The horizontal scroll bar is not visible at launch but must
become visible if the displayed text exceeds the number of columns displayed.
The text area must not be editable.
Replace my name in the frame title with your name.
No event handling is required for this part of the assignment.
Swing GUI Implementation
T
he Swing GUI implementation involves the following classes: Client, ClientChatUI,
Server,
and ServerChatUI.
Class Client
The class Client must contain only a main method. In the main method you must call
the
ClientChatUI constructor and then sets the appropriate frame properties before
making the frame visible. Do not forget that you must create the GUI in the eventdispatch thread.
Class ClientChatUI
The ClientChatUI class must inherit from JFrame.
It must have a constructor that takes the frame title. In the constructor you must set the
frame title and call a method
runClient().
The
ClientChatUI class must have a private inner class WindowController which
inherits from
WindowAdapter. You have to override the windowClosing() method. For
this part of the assignment you must simply call
System.exit(0) inside the method.
The
ClientChatUI class must have another private inner class Controller which inherits
from
ActionListener. The Controller will handle the user evens of the GUI. You have
to override the
actionPerformed() method. For this part of the assignment you can
implement the method with an empty body (NOP).
The
ClientChatUI class must have a public method createClientUI() which takes no
parameters and returns
JPanel. In that method the entire GUI must be created in a
JPanel and panel must be returned at the end of the method. A handler of type
Controller must be added to all buttons and the combo box.
CST – JAP, Assignment 2, Part 1, MMXX       Page 5 of 11
The private runClient() method takes no parameters and returns nothing. The method
calls the
createClientUI() and sets the content pane of the frame. It adds a window
listener to the frame using an object of
WindowController.
In the second part of the assignment more methods will be added and some of the
existing methods will be modified.
Class Server
The class Server must contain two method – the main() method and a static
launchClient() method. The launchClient() method contains two parameters – a Socket
and a String title. In the main method you must call launchClient() with a null argument
for the socket and a title string.
The
launchClient() method creates the GUI in the event-dispatch thread. It creates a
frame calling the
ServerChatUI() constructor with a null argument. The method sets the
frame title and the location of the frame before making the frame visible.
Class ServerChatUI
The ServerChatUI class must inherit from JFrame.
It must have a constructor that takes a
java.net.Socket parameter. In the constructor
you must set the class field
socket and call the setFrame() and runClient() methods.
The
ServerChatUI class must have a private inner class WindowController which
inherits from
WindowAdapter. You have to override the windowClosing() method. For
this part of the assignment you must simply dispose the frame and call
System.exit(0)
inside the method.
The
ServerChatUI class must have another private inner class Controller which
inherits from
ActionListener. The Controller will handle the Send button events of the
GUI. You have to override the
actionPerformed() method. For this part of the
assignment you can implement the method with an empty body (NOP).
The
ServerChatUI class must have a public method createUI() which takes no
parameters and returns
JPanel. In that method the entire GUI must be created in a
JPanel and the panel must be returned at the end of the method. It adds a handler of
type
Controller to the Send button.
The public
final void setFrame() takes a JPanel as a parameter and adds it to the
content pane of the frame. It set the size and the resizable properties of the frame. It
adds a window listener to the frame using an object of
WindowController and then
returns.
The private
runClient() method takes no parameters and returns nothing. For this part
of the assignment you can implement the method with an empty body (NOP).
In the second part of the assignment more methods will be added and some of the
existing methods will be modified.

CST – JAP, Assignment 2, Part 1, MMXX       Page 11 of 11
Task:
Build the specified Swing or JavaFX GUI. The GUI screenshots have been taken under
Windows 10 with the default “look and feel” with the image is captured with a screen
resolution 1366X768. If you are using some other operating platform, you may have a
different “look and feel” but the properties of all of the components and their relative
locations must be the same. On your platform the frame title maybe left-justified.
What to Submit:
No digital submission on Brightspace is required for this part of Assignment #2 Part 1
but you have to demonstrate you working GUI during the first 90 minutes of your Lab
period during
week 12 of the semester.
Marking Scheme:
5 marks –
The GUI must meet all requirements and must look exactly the same as
the one shown in the figures.
4 marks – The Client GUI looks exactly the same as the one shown in the figures but
does not meet two of the requirements.
3 marks – The Client GUI has all of the required components but they are not
properly aligned and sized, or the GUI does not meet three or more
requirements.
0 marks – The Client GUI is missing a component.
Enjoy the assignment. And do not forget that
“To have a server you ought to have a client first.” Business Rule #1
CST8221 – JAP, 27 February 2020, S^R

 

 

  • 相关文章:

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Walle Build 100427

Copyright 代写C.