Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lab10
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9731087
Lab10
Commits
6b792e98
Commit
6b792e98
authored
May 19, 2019
by
9731087
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First Phase
parent
bee67334
Pipeline
#634
failed with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
9 deletions
+53
-9
ChatRoomGUI.java
src/ChatRoomGUI.java
+10
-1
Main.java
src/Main.java
+1
-2
MessageArea.java
src/MessageArea.java
+20
-1
ParticipantsArea.java
src/ParticipantsArea.java
+20
-3
UsernameFrame.java
src/UsernameFrame.java
+2
-2
No files found.
src/ChatRoomGUI.java
View file @
6b792e98
...
...
@@ -10,13 +10,22 @@ public class ChatRoomGUI extends JFrame {
public
ChatRoomGUI
()
{
super
();
this
.
setTitle
(
WINDOWS_TITLE
);
this
.
setLayout
(
n
ull
);
this
.
setLayout
(
n
ew
BorderLayout
()
);
this
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
this
.
setSize
(
WIDTH
,
HEIGHT
);
this
.
setLocation
(
X
,
Y
);
this
.
setVisible
(
true
);
ChatArea
chatBox
=
new
ChatArea
();
this
.
add
(
new
JScrollPane
(
chatBox
),
BorderLayout
.
CENTER
);
MessageArea
messageArea
=
new
MessageArea
();
this
.
add
(
messageArea
,
BorderLayout
.
SOUTH
);
this
.
setVisible
(
true
);
ParticipantsArea
participantsArea
=
new
ParticipantsArea
();
this
.
add
(
participantsArea
,
BorderLayout
.
WEST
);
participantsArea
.
addNewParticipant
(
" Amirmehdy"
);
participantsArea
.
addNewParticipant
(
" Abtin"
);
participantsArea
.
removeParticipant
(
" Amirmehdy"
);
this
.
setVisible
(
true
);
}
...
...
src/Main.java
View file @
6b792e98
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
//System.out.println("Hello World!");
//UsernameFrame usernameFrame = new UsernameFrame();
ChatRoomGUI
chatRoomGUI
=
new
ChatRoomGUI
();
UsernameFrame
u
=
new
UsernameFrame
();
}
}
src/MessageArea.java
View file @
6b792e98
public
class
MessageArea
{
import
javax.swing.*
;
import
java.awt.*
;
public
class
MessageArea
extends
JPanel
{
JTextField
msg
=
new
JTextField
();
JTextField
textField
;
JButton
btn
;
private
static
final
String
BTN_TXT
=
"Send Message"
;
public
MessageArea
()
{
super
();
this
.
setLayout
(
new
BorderLayout
());
textField
=
new
JTextField
();
add
(
textField
,
BorderLayout
.
CENTER
);
btn
=
new
JButton
(
BTN_TXT
);
add
(
btn
,
BorderLayout
.
EAST
);
setVisible
(
true
);
}
}
src/ParticipantsArea.java
View file @
6b792e98
public
class
ParticipantsArea
{
import
javax.swing.*
;
import
java.awt.*
;
public
class
ParticipantsArea
extends
JPanel
{
public
void
addNewParticipant
(
String
username
)
{
private
static
final
String
LABEL_TXT
=
"Online People: "
;
DefaultListModel
model
;
public
ParticipantsArea
()
{
super
();
this
.
setLayout
(
new
BorderLayout
());
JLabel
label
=
new
JLabel
(
LABEL_TXT
);
add
(
label
,
BorderLayout
.
PAGE_START
);
model
=
new
DefaultListModel
();
JList
list
=
new
JList
(
model
);
add
(
list
,
BorderLayout
.
CENTER
);
setVisible
(
true
);
}
public
void
removeParticipant
(
String
username
)
{
public
void
addNewParticipant
(
String
username
)
{
model
.
addElement
(
username
);
}
public
void
removeParticipant
(
String
username
)
{
model
.
removeElement
(
username
);
}
}
src/UsernameFrame.java
View file @
6b792e98
...
...
@@ -11,11 +11,11 @@ public class UsernameFrame extends JFrame {
public
UsernameFrame
()
throws
HeadlessException
{
super
();
this
.
setLayout
(
new
BorderLayout
());
JLabel
label
=
new
JLabel
(
"Choose Your UserName"
);
JLabel
label
=
new
JLabel
(
LABEL_TXT
);
add
(
label
,
BorderLayout
.
PAGE_START
);
textField
=
new
JTextField
();
add
(
textField
,
BorderLayout
.
CENTER
);
btn
=
new
JButton
(
LABEL
_TXT
);
btn
=
new
JButton
(
BTN
_TXT
);
add
(
btn
,
BorderLayout
.
PAGE_END
);
setSize
(
WIDTH
,
HEIGHT
);
setVisible
(
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment