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
9731082
lab10
Commits
6ee2662f
Commit
6ee2662f
authored
May 21, 2019
by
armin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asli
parent
ed846537
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
77 deletions
+0
-77
RemoveFrame.java
src/RemoveFrame.java
+0
-77
No files found.
src/RemoveFrame.java
deleted
100644 → 0
View file @
ed846537
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.KeyAdapter
;
import
java.awt.event.KeyEvent
;
public
class
RemoveFrame
extends
JFrame
{
private
static
final
String
BTN_TXT
=
" Start Chatting ..."
;
private
static
final
String
LABEL_TXT
=
" Choose Your UserName "
;
private
static
final
int
WIDTH
=
300
,
HEIGHT
=
200
;
public
static
ChatRoomGUI
mainChatRoom
;
JTextField
textField
;
JButton
btn
;
public
String
userName
;
public
static
ChatRoomGUI
getMainChatRoom
()
{
return
mainChatRoom
;
}
public
RemoveFrame
()
throws
HeadlessException
{
super
();
this
.
setLayout
(
new
BorderLayout
());
JLabel
label
=
new
JLabel
(
"Choose Your UserName"
);
add
(
label
,
BorderLayout
.
PAGE_START
);
textField
=
new
JTextField
();
add
(
textField
,
BorderLayout
.
CENTER
);
btn
=
new
JButton
(
"Enter Your UserName"
);
btn
.
addActionListener
(
new
ActionListener
(){
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
userName
=
textField
.
getText
();
setVisible
(
false
);
mainChatRoom
=
new
ChatRoomGUI
();
mainChatRoom
.
removePart
(
userName
);
JTextField
txtField
=
mainChatRoom
.
getMessageArea
().
getTextField
();
txtField
.
addKeyListener
(
new
KeyAdapter
()
{
public
void
keyPressed
(
KeyEvent
evt
)
{
if
(
evt
.
getKeyCode
()
==
KeyEvent
.
VK_ENTER
&&
!
evt
.
isShiftDown
())
{
String
txt
=
mainChatRoom
.
getMessageArea
().
getTextField
().
getText
();
mainChatRoom
.
getChatBox
().
addMessage
(
userName
,
txt
);
mainChatRoom
.
getMessageArea
().
setTextField
(
""
);
}
else
if
(
evt
.
getKeyCode
()
==
KeyEvent
.
VK_ENTER
)
txtField
.
setText
(
txtField
.
getText
()+
'\n'
);
else
txtField
.
setText
(
txtField
.
getText
()+
evt
.
getKeyChar
());
}
});
JButton
btn
=
mainChatRoom
.
getMessageArea
().
getBtn
();
btn
.
addActionListener
(
new
ActionListener
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
String
txt
=
mainChatRoom
.
getMessageArea
().
getTextField
().
getText
();
mainChatRoom
.
getChatBox
().
addMessage
(
userName
,
txt
);
mainChatRoom
.
getMessageArea
().
setTextField
(
""
);
}
});
}
});
add
(
btn
,
BorderLayout
.
PAGE_END
);
setSize
(
WIDTH
,
HEIGHT
);
setVisible
(
true
);
this
.
setBackground
(
Color
.
green
);
}
public
String
getUserName
()
{
return
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