Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
project-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
Amirhosein Rajabpour
project-Lab10
Commits
931535cc
Commit
931535cc
authored
May 19, 2019
by
Amirhosein Rajabpour
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
second commit
parent
f0005cc9
Pipeline
#633
failed with stages
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
ChatRoomGUI.java
src/ChatRoomGUI.java
+8
-1
ParticipantsArea.java
src/ParticipantsArea.java
+10
-6
No files found.
src/ChatRoomGUI.java
View file @
931535cc
...
@@ -23,9 +23,16 @@ public class ChatRoomGUI extends JFrame{
...
@@ -23,9 +23,16 @@ public class ChatRoomGUI extends JFrame{
this
.
add
(
messagebox
,
BorderLayout
.
PAGE_END
);
this
.
add
(
messagebox
,
BorderLayout
.
PAGE_END
);
ParticipantsArea
participantsArea
=
new
ParticipantsArea
();
ParticipantsArea
participantsArea
=
new
ParticipantsArea
();
this
.
add
(
participantsArea
,
BorderLayout
.
WEST
);
this
.
add
(
new
JScrollPane
(
participantsArea
),
BorderLayout
.
WEST
);
participantsArea
.
addNewParticipant
(
"akbar"
);
participantsArea
.
removeParticipant
(
"akbar"
);
participantsArea
.
addNewParticipant
(
"ali"
);
participantsArea
.
addNewParticipant
(
"asghar"
);
this
.
setVisible
(
true
);
this
.
setVisible
(
true
);
}
}
}
}
\ No newline at end of file
src/ParticipantsArea.java
View file @
931535cc
import
javax.swing.*
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.*
;
import
java.util.ArrayList
;
import
javax.swing.JList
;
import
javax.swing.JList
;
public
class
ParticipantsArea
extends
JPanel
{
public
class
ParticipantsArea
extends
JPanel
{
DefaultListModel
model
;
JList
userslist
;
public
ParticipantsArea
(){
public
ParticipantsArea
(){
super
();
JLabel
label
=
new
JLabel
(
"online users"
);
JLabel
label
=
new
JLabel
(
"online users"
);
add
(
label
,
BorderLayout
.
NORTH
);
add
(
label
,
BorderLayout
.
PAGE_START
);
this
.
setLayout
(
new
GridLayout
(
10
,
1
));
model
=
new
DefaultListModel
();
userslist
=
new
JList
(
model
);
this
.
add
(
userslist
,
BorderLayout
.
CENTER
);
}
}
DefaultListModel
model
=
new
DefaultListModel
();
JList
userslist
=
new
JList
(
model
);
public
void
addNewParticipant
(
String
userName
){
public
void
addNewParticipant
(
String
userName
){
if
(!
model
.
contains
(
userName
))
if
(!
model
.
contains
(
userName
))
model
.
addElement
(
userName
);
model
.
addElement
(
userName
);
// System.out.println(model);
}
}
public
void
removeParticipant
(
String
userName
){
public
void
removeParticipant
(
String
userName
){
...
...
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